Properties

$filters

$filters : 

Supported filters.

Type

$current

$current : 

Current document parsed.

Type

$meta

$meta : 

Hold meta information for filters to use.

Type

Methods

getUntilStop()

getUntilStop(string  $text) : string

Get text until <!--stop--> or all text.

Parameters

string $text

with content

Returns

string —

with text

getUntilMore()

getUntilMore(string  $text) : array

Get text until <!--more--> or all text.

Parameters

string $text

with content

Returns

array —

with text and boolean if more was detected.

wrapElementWithStartEnd()

wrapElementWithStartEnd(string  $text, string  $tag, string  $start, string  $end, \Anax\TextFilter\number  $count) : array

Wrap HTML element with with start and end.

Parameters

string $text

with content

string $tag

HTML tag to search for

string $start

wrap start part

string $end

wrap end part

\Anax\TextFilter\number $count

hits to search for

Returns

array —

with text and boolean if more was detected.

wrapElementContentWithStartEnd()

wrapElementContentWithStartEnd(string  $text, string  $tag, string  $start, string  $end, \Anax\TextFilter\number  $count) : array

Wrap content of a HTML element with start and end.

Parameters

string $text

with content

string $tag

HTML tag to search for

string $start

wrap start part

string $end

wrap end part

\Anax\TextFilter\number $count

hits to search for

Returns

array —

with text and boolean if more was detected.

createToc()

createToc(string  $text, integer  $start = 2, integer  $stop = 4) : array

Create a TOC of HTML headings from and to a certain level.

Parameters

string $text

with content

integer $start

level of headings to use for toc.

integer $stop

level of headings to use for toc.

Returns

array —

with entries to generate a TOC.

createAnchor4Header()

createAnchor4Header(string  $text, integer  $start = 1, integer  $stop = 4) : string

Create a anchor for each header having an id.

Parameters

string $text

with content

integer $start

level of headings to use.

integer $stop

level of headings to use.

Returns

string —

with modified text.

addBaseurlToRelativeLinks()

addBaseurlToRelativeLinks(string  $text, string  $baseurl, callable  $callback) : string

Add baseurl to all relative links.

Parameters

string $text

with content.

string $baseurl

as string to prepend relative link.

callable $callback

Use to create url from route.

Returns

string —

with modified text.

addBaseurlToImageSource()

addBaseurlToImageSource(string  $text, string  $baseurl, callable  $callback) : string

Add baseurl to all relative links in image source.

Parameters

string $text

with content.

string $baseurl

as string to prepend relative link.

callable $callback

Use to create url from route.

Returns

string —

with modified text.

addRevisionHistory()

addRevisionHistory(string  $text, array  $revision, string  $start, string  $end, string  $class, string  $source = null) : string

Generate revision history and add to the end of content.

Parameters

string $text

with content.

array $revision

with all revisions.

string $start

start wrap with this.

string $end

end wrap with this.

string $class

to add to ul element.

string $source

optional url to document source.

Returns

string —

with text and optionally added revision history.

shortCode()

shortCode(string  $text) : string

Shortcode to quicker format text as HTML.

Parameters

string $text

text to be converted.

Returns

string —

the formatted text.

shortCodeInit()

shortCodeInit(string  $options) : array

Init shortcode handling by preparing the option list to an array, for those using arguments.

Parameters

string $options

for the shortcode.

Returns

array —

with all the options.

shortCodeYoutube()

shortCodeYoutube(string  $options) : array

Shortcode for [YOUTUBE].

Usage example: [YOUTUBE src=id-for-the-tube width=630 caption=""]

Parameters

string $options

for the shortcode.

Returns

array —

with all the options.

shortCodeFigure()

shortCodeFigure(string  $options) : array

Shortcode for <figure>.

Usage example: [FIGURE src="img/home/me.jpg" caption="Me" alt="Bild på mig" nolink="nolink"]

Parameters

string $options

for the shortcode.

Returns

array —

with all the options.

shortCodeAsciinema()

shortCodeAsciinema(string  $options) : array

Shortcode for [asciinema].

Parameters

string $options

for the shortcode.

Returns

array —

with all the options.

shortCodeBook()

shortCodeBook(string  $options) : array

Shortcode for [book].

Parameters

string $options

for the shortcode.

Returns

array —

with all the options.

doFilter()

doFilter(string  $text, string|array  $filters) : string

Call each filter.

Parameters

string $text

the text to filter.

string|array $filters

as comma separated list of filter, or filters sent in as array.

Returns

string —

the formatted text.

setMeta()

setMeta(array  $meta) : void

Set meta information that some filters can use.

Parameters

array $meta

values for filters to use.

getFilters()

getFilters() : array

Return an array of all filters supported.

Returns

array —

with strings of filters supported.

hasFilter()

hasFilter(string  $filter) : boolean

Check if filter is supported.

Parameters

string $filter

to use.

Throws

\Anax\TextFilter\mos/TextFilter/Exception

when filter does not exists.

Returns

boolean —

true if filter exists, false othwerwise.

parse()

parse(string  $text, array  $filter) : array

Call each filter and return array with details of the formatted content.

Parameters

string $text

the text to filter.

array $filter

array of filters to use.

Throws

\Anax\TextFilter\mos/TextFilter/Exception

when filterd does not exists.

Returns

array —

with the formatted text and additional details.

addExcerpt()

addExcerpt(  $current) : \Anax\TextFilter\void.

Add excerpt as short version of text if available.

Parameters

$current

Returns

\Anax\TextFilter\void.

jsonFrontMatter()

jsonFrontMatter(string  $text) : array

Extract JSON front matter from text.

Parameters

string $text

the text to be parsed.

Returns

array —

with the formatted text and the front matter.

yamlFrontMatter()

yamlFrontMatter(string  $text) : array

Extract YAML front matter from text.

Parameters

string $text

the text to be parsed.

Returns

array —

with the formatted text and the front matter.

yamlParse()

yamlParse(string  $text) : array

Extract YAML front matter from text, use one of several available implementations of a YAML parser.

Parameters

string $text

the text to be parsed.

Throws

\Anax\TextFilter\:

Exception when parsing frontmatter fails.

Returns

array —

with the formatted text and the front matter.

getTitleFromFirstH1()

getTitleFromFirstH1(string  $text) : string|null

Get the title from the first H1.

Parameters

string $text

the text to be parsed.

Returns

string|null —

with the title, if its found.

getTitleFromFirstHeader()

getTitleFromFirstHeader(string  $text) : string|null

Get the title from the first header.

Parameters

string $text

the text to be parsed.

Returns

string|null —

with the title, if its found.

bbcode2html()

bbcode2html(string  $text) : string

Helper, BBCode formatting converting to HTML.

Parameters

string $text

The text to be converted.

Returns

string —

the formatted text.

makeClickable()

makeClickable(string  $text) : string

Make clickable links from URLs in text.

Parameters

string $text

the text that should be formatted.

Returns

string —

with formatted anchors.

syntaxHighlightJs()

syntaxHighlightJs(string  $text, string  $language = "text") : string

Syntax highlighter using highlight.php, a port of highlight.js https://packagist.org/packages/scrivo/highlight.php.

Parameters

string $text

text to be converted.

string $language

which language to use for highlighting syntax.

Returns

string —

the formatted text.

purify()

purify(string  $text) : string

Format text according to HTML Purifier.

Parameters

string $text

that should be formatted.

Returns

string —

as the formatted html-text.

markdown()

markdown(string  $text) : string

Format text according to Markdown syntax.

Parameters

string $text

the text that should be formatted.

Returns

string —

as the formatted html-text.

nl2br()

nl2br(string  $text) : string

For convenience access to nl2br

Parameters

string $text

text to be converted.

Returns

string —

the formatted text.

htmlentities()

htmlentities(string  $text) : string

For convenience access to htmlentities

Parameters

string $text

text to be converted.

Returns

string —

the formatted text.

addToFrontmatter()

addToFrontmatter(array|null  $matter) : $this

Add array items to frontmatter.

Parameters

array|null $matter

key value array with items to add or null if empty.

Returns

$this

parseFactory()

parseFactory(string  $filter) : string

Call a specific filter and store its details.

Parameters

string $filter

to use.

Throws

\Anax\TextFilter\mos/TextFilter/Exception

when filter does not exists.

Returns

string —

the formatted text.

extractFrontMatter()

extractFrontMatter(string  $text, string  $startToken, string  $stopToken) : array

Extract front matter from text.

Parameters

string $text

the text to be parsed.

string $startToken

the start token.

string $stopToken

the stop token.

Returns

array —

with the formatted text and the front matter.