Textpattern PHP Cross Reference Content Management Systems

Summary: /textpattern/vendors/Netcarver/Textile/Parser.php - 5308 lines - 156049 bytes - Source - Print

Description: Textile - A Humane Web Text Generator.

Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Parser:: (117 methods):
__construct()
configure()
setDocumentType()
getDocumentType()
setDocumentRootDirectory()
getDocumentRootDirectory()
setLite()
isLiteModeEnabled()
setImages()
isImageTagEnabled()
setLinkRelationShip()
getLinkRelationShip()
setRestricted()
isRestrictedModeEnabled()
setRawBlocks()
isRawBlocksEnabled()
setBlockTags()
isBlockTagEnabled()
setLineWrap()
isLineWrapEnabled()
setSymbol()
getSymbol()
setImagePrefix()
getImagePrefix()
setLinkPrefix()
getLinkPrefix()
setRelativeImagePrefix()
setDimensionlessImages()
getDimensionlessImages()
getVersion()
textileEncode()
parse()
textileThis()
textileRestricted()
textileCommon()
prepGlyphs()
getMaxLinkIndex()
prepare()
cleanAttribs()
newTag()
parseAttribs()
formatAttributeString()
parseAttribsToArray()
hasRawText()
tables()
fTable()
redclothLists()
fRedclothList()
textileLists()
fTextileList()
liType()
doTagBr()
doPBr()
fPBr()
fBr()
blocks()
fBlock()
isRawBlock()
formatFootnote()
replaceMarkers()
getHTMLComments()
fParseHTMLComments()
graf()
spans()
fSpan()
storeTags()
retrieveTags()
fRetrieveTags()
placeNoteLists()
fNoteLists()
makeBackrefLink()
fParseNoteDefs()
noteRefs()
fParseNoteRefs()
parseURI()
addPart()
rebuildURI()
links()
markStartOfLinks()
replaceLinks()
fLink()
getRefs()
refs()
shelveURL()
retrieveURLs()
retrieveURL()
isValidUrl()
relURL()
isRelURL()
images()
isInDocumentRootDirectory()
fImage()
code()
fCode()
fPre()
shelve()
retrieve()
cleanWhiteSpace()
cleanUniqueTokens()
doSpecial()
getSpecialOptions()
noTextile()
fTextile()
footnoteRefs()
footnoteID()
glyphQuotedQuote()
fGlyphQuotedQuote()
glyphs()
replaceGlyphs()
hAlign()
vAlign()
encodeHigh()
decodeHigh()
encodeHTML()
rEncodeHTML()
isMultiByteStringSupported()
isUnicodePcreSupported()

Class: Parser

Textile parser.

The Parser class takes Textile input and converts it to well formatted HTML.
This is the library's main class, hosting the parsing functionality and
exposing a simple public interface for you to use.

The most basic use case would involve initialising a instance of the class
and calling the Parser::parse() method:

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->parse('h1. Hello World!');

The above generates:

bc. <h1>Hello World!</h1>

The functionality of the parser can be customized with the setters:

bc. $parser = new \Netcarver\Textile\Parser();
$parser->setImages(false)->parse('!no-image.jpg!');

The Parser class can also be extended to create pre-configured classes:

bc.. namespace MyApp;

use \Netcarver\Textile\Parser;

class CommentParser extends Parser
{
protected function configure()
{
$this->setImages(false)->setRestricted(true)->setLite(true);
}
}

p. Keep in mind that the classes' protected methods and properties should be
considered part of the private API and depending on them should be avoided.
Instead try to only use the public methods marked as being part of the
public API.

__construct($doctype = 'xhtml')  line: 1091
Constructor.

The constructor allows setting options that affect the class instance as
a whole, such as the output doctype. To instruct the parser to return
HTML5 markup instead of XHTML, set $doctype argument to 'html5'.

bc. $parser = new \Netcarver\Textile\Parser('html5');
echo $parser->parse('HTML(HyperText Markup Language)");

param: string $doctype The output document type, either 'xhtml' or 'html5'
configure()  line: 1177
Configure the current parser.

This method can be extended to create a pre-configured parser class.

bc.. namespace MyApp;

use Netcarver\Textile\Parser;

class CommentParser extends Parser
{
protected function configure()
{
$this->setImages(false)->setRestricted(true)->setLite(true);
}
}

return: void Return value is ignored
setDocumentType($doctype line: 1203
Sets the output document type.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setDocumentType('html5')
->parse('HTML(HyperText Markup Language)");

return: Parser This instance
param: string $doctype Either 'xhtml' or 'html5'
getDocumentType()  line: 1232
Gets the current output document type.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->getDocumentType();

return: string The document type
setDocumentRootDirectory($path line: 1249
Sets the document root directory path.

This method sets the path that is used to resolve relative file paths
within local filesystem. This is used to fetch image dimensions, for
instance.

bc. $parser = new \Netcarver\Textile\Parser();
$parser->setDocumentRootDirectory('/path/to/document/root/dir');

If not set, document root defaults to the current working directory if
PHP-Textile is used via CLI. On server environment, DOCUMENT_ROOT or
PATH_TRANSLATED server variable is used based on which ever is available.

return: Parser This instance
param: string $path The root path
getDocumentRootDirectory()  line: 1276
Gets the current document root directory path.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->getDocumentRootDirectory();

return: string Path to the document root directory
setLite($lite line: 1293
Enables lite mode.

If enabled, allowed tags are limited. Parser will prevent the use extra
Textile formatting, accepting only paragraphs and blockquotes as valid
block tags.

bc. $parser = new \Netcarver\Textile\Parser();
$parser
->setLite(true)
->parse('h1. Headings are disabled too');

Generates:

bc. <p>h1. Headings are disabled too</p>

This doesn't prevent unsafe input values. If you wish to parse untrusted
user-given Textile input, also enable the restricted parser mode with
Parser::setRestricted().

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setRestricted(true)
->setLite(true)
->parse('h1. Hello World!');

return: Parser This instance
param: bool   $lite TRUE to enable
isLiteModeEnabled()  line: 1333
Gets the lite mode status.

bc. $parser = new \Netcarver\Textile\Parser();
if ($parser->isLiteModeEnabled() === true) {
echo 'Lite mode is enabled.';
}

return: bool TRUE if enabled, FALSE otherwise
setImages($enabled line: 1352
Disables and enables images.

If disabled, image tags are not generated. This option is ideal for
minimalist output such as text-only comments.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setImages(true)
->parse('!image.png!');

Generates:

bc. <p>!image.png!</p>

return: Parser This instance
param: bool   $enabled TRUE to enable, FALSE to disable
isImageTagEnabled()  line: 1380
Whether images are enabled.

bc. $parser = new \Netcarver\Textile\Parser();
if ($parser->isImageTagEnabled() === true) {
echo 'Images are enabled.';
}

return: bool TRUE if enabled, FALSE otherwise
setLinkRelationShip($relationship line: 1399
Sets link relationship status value.

This method sets the HTML relationship tokens that are applied to links
generated by PHP-Textile.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setLinkRelationShip('nofollow')
->parse('"Link":http://example.com/');

Generates:

bc. <p><a href="http://example.com/" rel="nofollow">Link</a></p>

return: Parser       This instance
param: string|array $relationship The HTML rel attribute value
getLinkRelationShip()  line: 1427
Gets the link relationship status value.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parse
->setLinkRelationShip('nofollow')
->getLinkRelationShip();

The above outputs "nofollow".

return: string The value
setRestricted($enabled line: 1448
Enables restricted parser mode.

This option should be enabled when parsing untrusted user input,
including comments or forum posts. When enabled, the parser escapes any
raw HTML input, ignores unsafe attributes and links only whitelisted URL
schemes.

For instance the following malicious input:

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setRestricted(true)
->parse('Innocent _looking_ "link":javacript:window.alert().');

Returns safe, sanitized HTML with valid Textile input still parsed:

bc. <p>Innocent <em>looking</em> &#8220;link&#8221;:javacript:window.alert().</p>

If left disabled, the parser allows users to mix raw HTML and Textile.
Using the parser in non-restricted on untrusted input, like comments
and forum posts, will lead to XSS issues, as users will be able to use
any HTML code, JavaScript links and Textile attributes in their input.

return: Parser This instance
param: bool   $enabled TRUE to enable, FALSE to disable
isRestrictedModeEnabled()  line: 1492
Whether restricted parser mode is enabled.

bc. $parser = new \Netcarver\Textile\Parser();
if ($parser->isRestrictedModeEnabled() === true) {
echo 'PHP-Textile is in restricted mode.';
}

return: bool   TRUE if enabled, FALSE otherwise
setRawBlocks($enabled line: 1511
Enables and disables raw blocks.

When raw blocks are enabled, any paragraph blocks wrapped in a tag
not matching Parser::$blockContent or Parser::$phrasingContent will not
be parsed, and instead is left as is.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setRawBlocks(true)
->parse('<div>A *raw* block.</div>');

The above generates:

bc. <div>A *raw* block.</div>

return: Parser This instance
param: bool   $enabled TRUE to enable, FALSE to disable
isRawBlocksEnabled()  line: 1541
Whether raw blocks are enabled.

bc. $parser = new \Netcarver\Textile\Parser();
if ($parser->isRawBlocksEnabled() === true) {
echo 'Raw blocks are enabled';
}

return: bool TRUE if enabled, FALSE otherwise
setBlockTags($enabled line: 1560
Enables and disables block-level tags and formatting features.

When disabled, block-level tags aren't rendered. This allows PHP-Textile
to operate on a single line of text, rather than blocks of text and does
not wrap the output in paragraph tags.

bc. $parser = new \Netcarving\Textile\Parser();
echo $parser
->setBlockTags(false)
->parse('h1. Hello *strong* world!');

The above generates:

bc. h1. Hello <strong>strong</strong> world!

return: Parser This instance
param: bool   $enabled TRUE to enable, FALSE to disable
isBlockTagEnabled()  line: 1589
Whether block-level tags are enabled and parsed.

bc. $parser = new \Netcarving\Textile\Parser();
if ($parser->isBlockTagAllowed() === true) {
echo 'Block tags are enabled.';
}

return: bool TRUE if enabled, FALSE otherwise
setLineWrap($enabled line: 1608
Enables and disables line-wrapping.

If enabled, line-breaks are replaced by target document's break tag. If
disabled, input document's line-breaks are ignored. This setting can be
used if the the input document's lines are pre-wrapped. For instance,
in case the input is from CLI content, or source code documentation.

bc. $parser = new \Netcarving\Textile\Parser();
echo $parser
->setLineWrap(false)
->parse("Hello\nworld!");

The above generates:

bc. <p>Hello world!</p>

return: Parser This instance
param: bool   $enabled TRUE to enable, FALSE to disable
isLineWrapEnabled()  line: 1638
Whether line-wrapping is enabled.

bc. $parser = new \Netcarving\Textile\Parser();
if ($parser->isLineWrapEnabled() === true) {
echo 'Line-wrapping is enabled.';
}

return: bool TRUE if enabled, FALSE otherwise
setSymbol($name, $value line: 1657
Sets a substitution symbol.

This method lets you to redefine a substitution symbol. The following
sets the 'half' glyph:

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setSymbol('half', '1&#8260;2')
->parse('Hello [1/2] World!');

Generates:

bc. <p>Hello 1&#⁄2 World!</p>

Symbol can be set to FALSE to disable it:

bc. $parser = new \Netcarver\Textile\Parser();
$parser->setSymbol('dimension', false);

See Parser::getSymbol() to find out all available symbols.

return: Parser      This instance
param: string      $name  Name of the symbol to assign a new value to
param: string|bool $value New value for the symbol, or FALSE to disable
getSymbol($name = null)  line: 1697
Gets a symbol definitions.

This method gets a symbol definition by name, or the full symbol table
as an array.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->getSymbol('dimension');

To get all available symbol definitions:

bc. $parser = new \Netcarver\Textile\Parser();
print_r($parser->getSymbol());

return: array|string The symbol table or the requested symbol
param: string|null  $name The name of the symbol, or NULL if requesting the symbol table
setImagePrefix($prefix line: 1731
Sets base relative image prefix.

The given string is used to prefix relative image paths, usually an
absolute HTTP address pointing a the site's image, or upload, directory.
PHP-Textile to convert relative paths to absolute, or prefixed paths.

bc. $parser = new \Netcarver\Textile\Parser();
$parser->setImagePrefix('https://static.example.com/images/');

return: Parser This instance
param: string $prefix The prefix
getImagePrefix()  line: 1754
Gets base relative image prefix.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->getImagePrefix();

return: string The prefix
setLinkPrefix($prefix line: 1771
Sets base relative link prefix.

The given string is used to prefix relative link paths. This allows
PHP-Textile convert relative paths to absolute, or prefixed, links.

bc. $parser = new \Netcarver\Textile\Parser();
$parser->setLinkPrefix('https://example.com/');

return: Parser This instance
param: string $prefix The prefix
getLinkPrefix()  line: 1793
Gets base relative link prefix.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->getLinkPrefix();

return: string The prefix
setRelativeImagePrefix($prefix = '')  line: 1810
Sets base relative image and link directory path.

This is used when Textile is supplied with a relative image or link path.
Allows client systems to have PHP-Textile convert relative paths to
absolute or prefixed paths. This method is used to set that base path,
usually an absolute HTTP address pointing to a directory. Note that
despite its name it applies to both links and images.

bc. $parser = new \Netcarver\Textile\Parser();
$parser->setRelativeImagePrefix('https://example.com/');

return: Parser This instance
param: string $prefix The string to prefix all relative image paths with
setDimensionlessImages($dimensionless = true)  line: 1842
Enables dimensionless images.

If enabled, image width and height attributes will not be included in
rendered image tags. Normally, PHP-Textile will add width and height
to images linked with a local relative path, as long as the image file
can be accessed.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setDimensionlessImages(true)
->parse('!image.jpg!');

return: Parser This instance
param: bool   $dimensionless TRUE to disable image dimensions, FALSE to enable
getDimensionlessImages()  line: 1867
Whether dimensionless images are enabled.

bc. $parser = new \Netcarver\Textile\Parser();
if ($parser->getDimensionlessImages() === true) {
echo 'Images do not get dimensions.';
}

return: bool TRUE if images will not get dimensions, FALSE otherwise
getVersion()  line: 1885
Gets PHP-Textile version number.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->getVersion();

return: string Version number
textileEncode($text line: 1900
Encodes the given text.

bc. $parser = new \Netcarver\Textile\Parser();
$parser->textileEncode('Some content to encode.');

return: string The encoded text
param: string $text The text to be encoded
parse($text line: 1916
Parses the given Textile input according to the previously set options.

The parser's features can be changed by using the various public setter
methods this class has. The most basic use case is:

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->parse('h1. Hello World!');

The above parses trusted input in full-feature mode, generating:

bc. <h1>Hello World!</h1>

Additionally the parser can be run in safe, restricted mode using the
Parser::setRestricted() method.

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setRestricted(true)
->parse('h1. Hello World!');

This enables restricted mode and allows safe parsing of untrusted input.
PHP-Textile will disable unsafe attributes, links and escapes any raw
HTML input. This option should be enabled when parsing untrusted user
input.

If restricted mode is disabled, the parser allows users to mix raw HTML
and Textile.

return: string Parsed Textile input
param: string $text The Textile input to parse
textileThis($text, $lite = false, $encode = false, $noimage = false, $strict = false, $rel = '')  line: 2005
Parses the given Textile input in un-restricted mode.

This method is deprecated, use Parser::parse() method instead.
This method is equilavent of:

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser->parse('h1. Hello World!');

Additinal arguments can be passed with setter methods:

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setLite(true)
->setImages(true)
->setLinkRelationShip('nofollow')
->parse('h1. Hello World!');

return: string Parsed $text
param: string $text    The Textile input to parse
param: bool   $lite    Switch to lite mode
param: bool   $encode  Encode input and return
param: bool   $noimage Disables images
param: bool   $strict  This argument is ignored
param: string $rel     Relationship attribute applied to generated links
textileRestricted($text, $lite = true, $noimage = true, $rel = 'nofollow')  line: 2060
Parses the given Textile input in restricted mode.

This method is deprecated, use Parser::parse() method with
Parser::setRestricted() and Parser::setLite() enabled, and
Parser::setImages() disabled.

This method's defaults are identical to:

bc. $parser = new \Netcarver\Textile\Parser();
echo $parser
->setRestricted(true)
->setLite(true)
->setImages(false)
->setLinkRelationShip('nofollow')
->parse('h1. Hello World!');

As in the above, restricted mode should be used when parsing any
untrusted user input, including comments or forum posts.

return: string Parsed input
param: string $text    The Textile input to parse
param: bool   $lite    Controls lite mode, allowing extra formatting
param: bool   $noimage Allow images
param: string $rel     Relationship attribute applied to generated links
textileCommon($text, $lite line: 2110
Parses Textile syntax.

This method performs common parse actions.

return: string Parsed input
param: string $text The input to parse
param: bool   $lite Enables lite mode
prepGlyphs()  line: 2127
Prepares the glyph patterns from the symbol table.

getMaxLinkIndex()  line: 2313
Gets the maximum allowed link index.

return: int Maximum link index
prepare($lite = null, $noimage = null, $rel = null)  line: 2325
Prepares the parser for parsing.

This method prepares the transient internal state of
Textile parser in preparation for parsing a new document.

param: bool|null   $lite    Controls lite mode
param: bool|null   $noimage Disallow images
param: string|null $rel     A relationship attribute applied to links
cleanAttribs($in line: 2399
Cleans a HTML attribute value.

This method checks for presence of URL encoding in the value.
If the number encoded characters exceeds the thereshold,
the input is discarded. Otherwise the encoded
instances are decoded.

This method also strips any ", ' and = characters
from the given value. This method does not guarantee
valid HTML or full sanitization.

return: string Cleaned string
param: string $in The input string
newTag($name, $atts, $selfclosing = true)  line: 2440
Constructs a HTML tag from an object.

This is a helper method that creates a new
instance of \Netcarver\Textile\Tag.

return: Tag
param: string $name        The HTML element name
param: array  $atts        HTML attributes applied to the tag
param: bool   $selfclosing Determines if the tag should be selfclosing
parseAttribs($in, $element = '', $include_id = true, $autoclass = '')  line: 2457
Parses Textile attributes.

return: string HTML attribute list
param: string $in         The Textile attribute string to be parsed
param: string $element    Focus the routine to interpret the attributes as applying to a specific HTML tag
param: bool   $include_id If FALSE, IDs are not included in the attribute list
param: string $autoclass  An additional classes applied to the output
formatAttributeString(array $attribute_array line: 2475
Converts an array of named attribute => value mappings to a string.

return: string
param: array $attribute_array
parseAttribsToArray($in, $element = '', $include_id = true, $autoclass = '')  line: 2495
Parses Textile attributes into an array.

return: array  HTML attributes as key => value mappings
param: string $in         The Textile attribute string to be parsed
param: string $element    Focus the routine to interpret the attributes as applying to a specific HTML tag
param: bool   $include_id If FALSE, IDs are not included in the attribute list
param: string $autoclass  An additional classes applied to the output
hasRawText($text line: 2678
Checks whether the text block should be wrapped in a paragraph.

return: bool   TRUE if the text can be wrapped, FALSE otherwise
param: string $text The input string
tables($text line: 2706
Parses textile table structures into HTML.

return: string The parsed text
param: string $text The textile input
fTable($matches line: 2724
Constructs a HTML table from a textile table structure.

This method is used by Parser::tables() to process
found table structures.

return: string HTML table
param: array  $matches
redclothLists($text line: 2890
Parses RedCloth-style definition lists into HTML.

return: string The parsed text
param: string $text The textile input
fRedclothList($m line: 2906
Constructs a HTML definition list from a RedCloth-style definition structure.

This method is used by Parser::redclothLists() to process
found definition list structures.

return: string HTML definition list
param: array  $m
textileLists($text line: 2984
Parses Textile list structures into HTML.

Searches for ordered, un-ordered and definition lists in the
textile input and generates HTML lists for them.

return: string The parsed text
param: string $text The input
fTextileList($m line: 3003
Constructs a HTML list from a Textile list structure.

This method is used by Parser::textileLists() to process
found list structures.

return: string HTML list
param: array  $m
liType($in line: 3139
Determines the list type from the Textile input symbol.

return: string Either 'd', 'o', 'u'
param: string $in Textile input containing the possible list marker
doTagBr($tag, $in line: 3156
Adds br tags within the specified container tag.

return: string
param: string $tag The tag
param: string $in  The input
doPBr($in line: 3173
Adds br tags to paragraphs and headings.

return: string
param: string $in The input
fPBr($m line: 3189
Less restrictive version of fBr method.

Used only in paragraphs and headings where the next row may
start with a smiley or perhaps something like '#8 bolt...'
or '*** stars...'.

return: string
param: array $m The input
fBr($m line: 3222
Formats line breaks.

return: string
param: array  $m The input
blocks($text line: 3240
Splits the given input into blocks.

Blocks are separated by double line-break boundaries, and processed
the blocks one by one.

return: string Input text with blocks processed
param: string $text Textile source text
fBlock($m line: 3353
Formats the given block.

Adds block tags and formats the text content inside
the block.

return: array
param: array $m The block content to format
isRawBlock($text line: 3464
Whether the block is a raw document node.

Raw blocks will be shelved and left as is.

return: bool   TRUE if the block is raw, FALSE otherwise
param: string $text Block to check
formatFootnote($marker, $atts = '', $anchor = true)  line: 3491
Formats a footnote.

return: string Processed footnote
param: string $marker The marker
param: string $atts   Attributes
param: bool   $anchor TRUE, if its a reference link
replaceMarkers($text, $replacements line: 3506
Replaces markers with replacements in the given input.

return: string
param: string $text         The input
param: array  $replacements Marker replacement pairs
getHTMLComments($text line: 3525
Parses HTML comments in the given input.

This method finds HTML comments in the given input
and replaces them with reference tokens.

return: string $text Processed input
param: string $text Textile input
fParseHTMLComments($m line: 3544
Formats a HTML comment.

Stores the comment on the shelf and returns
a reference token wrapped in to a HTML comment.

return: string Reference token wrapped to a HTML comment tags
param: array  $m Options
graf($text line: 3559
Parses paragraphs in the given input.

return: string Processed input
param: string $text Textile input
spans($text line: 3618
Replaces Textile span tags with their equivalent HTML inline tags.

return: string The Textile document with spans replaced by their HTML inline equivalents
param: string $text The Textile document to perform the replacements in
fSpan($m line: 3655
Formats a span tag and stores it on the shelf.

return: string Content wrapped to reference tokens
param: array  $m Options
storeTags($opentag, $closetag = '')  line: 3684
Stores a tag pair in the tag cache.

return: array  Reference tokens for both opening and closing tag
param: string $opentag  Opening tag
param: string $closetag Closing tag
retrieveTags($text line: 3707
Replaces reference tokens with corresponding shelved span tags.

This method puts all shelved span tags back to the final,
parsed input.

return: string Processed text
param: string $text The input
fRetrieveTags($m line: 3735
Retrieves a tag from the tag cache.

return: string
param: array $m Options
placeNoteLists($text line: 3748
Parses note lists in the given input.

This method should be ran after other blocks
have been processed, but before reference tokens
have been replaced with their replacements.

return: string Processed input
param: string $text Textile input
fNoteLists($m line: 3793
Formats a note list.

return: string Processed note list
param: array  $m Options
makeBackrefLink($info, $g_links, $i line: 3844
Renders a note back reference link.

This method renders an array of back reference
links for notes.

return: string Processed input
param: array  $info    Options
param: string $g_links Reference type
param: string $i       Instance count
fParseNoteDefs($m line: 3882
Formats note definitions.

This method formats notes and stores them in
note cache for later use and to build reference
links.

return: string Empty string
param: array  $m Options
noteRefs($text line: 3916
Parses note references in the given input.

This method replaces note reference tags with
links.

return: string
param: string $text Textile input
fParseNoteRefs($m line: 3935
Formats note reference links.

By the time this function is called, all note lists will have been
processed into the notes array, and we can resolve the link numbers in
the order we process the references.

return: string Note reference
param: array  $m Options
parseURI($uri, &$m line: 3986
Parses URI into component parts.

This method splits a URI-like string apart into component parts, while
also providing validation.

return: bool   TRUE if the string validates as a URI
param: string $uri The string to pick apart (if possible)
param: array  $m   Reference to an array the URI component parts are assigned to
addPart($mask, $name, $parts line: 4009
Checks whether a component part can be added to a URI.

return: bool   TRUE if the component can be added
param: array  $mask  An array of allowed component parts
param: string $name  The component to add
param: array  $parts An array of existing components to modify
rebuildURI($parts, $mask = 'scheme,authority,path,query,fragment', $encode = true)  line: 4023
Rebuild a URI from parsed parts and a mask.

return: string         The rebuilt URI
param: array  $parts  Full array of URI parts
param: string $mask   Comma separated list of URI parts to include in the rebuilt URI
param: bool   $encode Flag to control encoding of the path part of the rebuilt URI
links($text line: 4074
Parses and shelves links in the given input.

This method parses the input Textile document for links.
Formats and encodes them, and stores the created link
elements in cache.

return: string The input document with link pulled out and replaced with tokens
param: string $text Textile input
markStartOfLinks($text line: 4091
Finds and marks the start of well formed links in the input text.

return: string Text with links marked
param: string $text String to search for link starting positions
replaceLinks($text line: 4209
Replaces links with tokens and stores them on the shelf.

return: string Processed input
param: string $text The input
fLink($m line: 4245
Formats a link and stores it on the shelf.

return: string Reference token for the shelved content
param: array  $m Options
getRefs($text line: 4452
Finds URI aliases within the given input.

This method finds URI aliases in the Textile input. Links are stored
in an internal cache, so that they can be referenced from any link
in the document.

This operation happens before the actual link parsing takes place.

return: string The Textile document with any URI aliases removed
param: string $text Textile input
refs($m line: 4485
Parses, encodes and shelves the current URI alias.

return: string Empty string
param: array $m Options
shelveURL($text, $type = null)  line: 4502
Shelves parsed URLs.

Stores away a URL fragments that have been parsed
and requires no more processing.

return: string The fragment's unique reference ID
param: string $text  The URL
param: string $type  The type
retrieveURLs($text line: 4528
Replaces reference tokens with corresponding shelved URL.

This method puts all shelved URLs back to the final,
parsed input.

return: string Processed text
param: string $text The input
retrieveURL($m line: 4548
Retrieves an URL from the shelve.

return: string The URL
param: array  $m Options
isValidUrl($url line: 4570
Whether the URL is valid.

Checks are done according the used preferences to
determinate whether the URL should be accepted and
essentially whether its safe.

return: bool   TRUE if valid, FALSE otherwise
param: string $url The URL to check
relURL($url, $type = null)  line: 4597
Completes and formats a relative URL.

This method adds $this->relativeImagePrefix to the
URL if it is relative.

The URI is kept as is if it starts with a '/', './', '../',
or the URL starts with one of $this->url_schemes. Otherwise
the URL is prefixed.

return: string Absolute URL
param: string $url  The URL
param: string $type The type
isRelURL($url line: 4642
Checks if an URL is relative.

The given URL is considered relative if it
start anything other than with '//' or a
valid scheme.

return: bool   TRUE if relative, FALSE otherwise
param: string $url The URL
images($text line: 4668
Parses and shelves images in the given input.

This method parses the input Textile document for images and
generates img HTML tags for each one found, caching the
generated img tag internally and replacing the Textile image with a
token to the cached tag.

return: string The input document with images pulled out and replaced with tokens
param: string $text Textile input
isInDocumentRootDirectory($path line: 4701
Checks that the given path is under the document root.

return: bool   TRUE if path is within the image document root
param: string $path Path to check
fImage($m line: 4723
Formats an image and stores it on the shelf.

return: string Reference token for the shelved content
param: array  $m Options
code($text line: 4795
Parses code blocks in the given input.

return: string Processed text
param: string $text The input
fCode($m line: 4810
Formats inline code tags.

return: string
param: array  $m
fPre($m line: 4824
Formats pre tags.

return: string
param: array  $m Options
shelve($val line: 4838
Shelves parsed content.

Stores away a fragment of the source text that have been parsed
and requires no more processing.

return: string The fragment's unique reference ID
param: string $val The content
retrieve($text line: 4856
Replaces reference tokens with corresponding shelved content.

This method puts all shelved content back to the final,
parsed input.

return: string Processed text
param: string $text The input
cleanWhiteSpace($text line: 4879
Removes BOM and unifies line ending in the given input.

return: string Cleaned version of the input
param: string $text Input Textile
cleanUniqueTokens($text line: 4899
Removes any unique tokens from the input.

return: string Cleaned input
param: string $text The input to clean
doSpecial($text, $start, $end, $method line: 4912
Uses the specified callback method to format the content between end and start nodes.

return: string Processed input
param: string $text   The input to format
param: string $start  The start node to look for
param: string $end    The end node to look for
param: string $method The callback method
getSpecialOptions($m line: 4933
Gets an array of processed special options.

return: array
param: array $m Options
noTextile($text line: 4954
Parses notextile tags in the given input.

return: string Processed input
param: string $text The input
fTextile($m line: 4967
Format notextile blocks.

return: string
param: array $m Options
footnoteRefs($text line: 4981
Parses footnote reference links in the given input.

This method replaces [n] instances with links.

return: string $text Processed input
param: string $text The input
footnoteID($m line: 5001
Renders a footnote reference link or ID.

return: string Footnote link, or ID
param: array  $m Options
glyphQuotedQuote($text, $find = '"?|"[^"]+"')  line: 5024
Parses and shelves quoted quotes in the given input.

return: string
param: string $text The text to search for quoted quotes
param: string $find Pattern to search
fGlyphQuotedQuote($m line: 5042
Formats quoted quotes and stores it on the shelf.

return: string Input with quoted quotes removed and replaced with tokens
param: array  $m Named regular expression parts
glyphs($text line: 5080
Replaces glyphs in the given input.

This method performs typographical glyph replacements. The input is split
across HTML-like tags in order to avoid attempting glyph
replacements within tags.

return: string
param: string $text Input Textile
replaceGlyphs($text line: 5134
Replaces glyph references in the given input.

This method removes temporary glyph: instances
from the input.

return: string Processed input
param: string $text The input
hAlign($in line: 5149
Translates alignment tag into corresponding CSS text-align property value.

return: string CSS text-align value
param: string $in The Textile alignment tag
vAlign($in line: 5171
Translates vertical alignment tag into corresponding CSS vertical-align property value.

return: string CSS vertical-align value
param: string $in The Textile alignment tag
encodeHigh($text, $charset = 'UTF-8')  line: 5189
Converts character codes in the given input from HTML numeric character reference to character code.

Conversion is done according to Textile's multi-byte conversion map.

return: string Processed input
param: string $text    The input
param: string $charset The character set
decodeHigh($text, $charset = 'UTF-8')  line: 5208
Converts numeric HTML character references to character code.

return: string Processed input
param: string $text    The input
param: string $charset The character set
encodeHTML($str, $quotes = true)  line: 5227
Convert special characters to HTML entities.

This method's functionality is identical to PHP's own
htmlspecialchars(). In Textile this is used for sanitising
the input.

return: string Encoded string
param: string $str    The string to encode
param: bool   $quotes Encode quotes
rEncodeHTML($str, $quotes = true)  line: 5258
Convert special characters to HTML entities.

This is identical to encodeHTML(), but takes restricted
mode into account. When in restricted mode, only escapes
quotes.

return: string Encoded string
param: string $str    The string to encode
param: bool   $quotes Encode quotes
isMultiByteStringSupported()  line: 5281
Whether multiple mbstring extensions is loaded.

return: bool
isUnicodePcreSupported()  line: 5297
Whether PCRE supports UTF-8.

return: bool

title

Body