Korin API

Media
in package
implements NodeRule

Read onlyYes
FinalYes

Media files by the 5.5.1 types:

  • FORM, a media type, becomes a file extension: one 5.5.1 lists (image/jpeg → jpg, image/tiff → tif), another known one (image/png → png), x for application/x-x; a media type without one stays;
  • FILE becomes a path: file:///c:/My%20Photos/a.jpg → c:\My Photos\a.jpg, file:///x → /x, file://server/x → \server\x, a relative path without its percent-encoding; another URL (https://…) stays.

Every value is one that converts up to the same value again (a percent-encoding may come back in uppercase: https%3a/x is https%3A/x); anything else stays as it is.

Table of Contents

Interfaces

NodeRule
A rule for one structure at a time. Rules that look at every line of a record are grouped in {@see Rule\Nodes}, which walks each record once for all of them.

Methods

__construct()  : mixed
extension()  : string
needsPrepass()  : bool
Whether the rule needs Context::prepass(): facts about the whole input before the first record.
node()  : bool
Converts one structure (a record or a substructure; never a CONC/CONT line) with one of the rule's tags, as the structure is tagged when the walk reaches it, in place. Its substructures are visited after it, as they are when this returns.
normalize()  : string
Percent-encodings in uppercase: "%3a" and "%3A" are the same URL (RFC 3986, section 6.2.2.1).
path()  : string
tags()  : array<int, string>|null

Methods

__construct()

public __construct() : mixed

extension()

public extension(string $type) : string
Parameters
$type : string
Return values
string

needsPrepass()

Whether the rule needs Context::prepass(): facts about the whole input before the first record.

public needsPrepass() : bool
Return values
bool

node()

Converts one structure (a record or a substructure; never a CONC/CONT line) with one of the rule's tags, as the structure is tagged when the walk reaches it, in place. Its substructures are visited after it, as they are when this returns.

public node(Document $document, int $id, Context $context) : bool
Parameters
$document : Document
$id : int
$context : Context
Return values
bool —

false when the rule removed the structure: the rules after it and its substructures are skipped

normalize()

Percent-encodings in uppercase: "%3a" and "%3A" are the same URL (RFC 3986, section 6.2.2.1).

public static normalize(string $url) : string
Parameters
$url : string
Return values
string

path()

public path(string $url) : string
Parameters
$url : string
Return values
string

tags()

public tags() : array<int, string>|null
Return values
array<int, string>|null —

the tags of the structures the rule converts; null for every structure

On this page

Search results