Copied!

A generic parser for markdown-like languages.

Abstract
Properties
public $maximumNestingLevel
 
Methods
public parse( $text)
 

Parses the given text considering the full language.

This includes parsing block elements as well as inline elements.

public parseParagraph( $text)
 

Parses a paragraph without block elements (block elements are ignored).

Properties
protected $context
 
protected $escapeCharacters
 
  • var phpDocumentor\Reflection\Types\Array_ these are "escapeable" characters. When using one of these prefixed with a
    backslash, the character will be outputted without the backslash and is not interpreted
    as markdown.
Methods
protected blockTypes()
 
protected cleanup()
 

This method will be called after parse() and parseParagraph().

You can override it to do cleanup.

protected consumeParagraph( $lines, $current)
 

Consume lines for a paragraph

protected detectLineType( $lines, $current)
 

Given a set of lines and an index of a current line it uses the registed block types to
detect the type of this line.

protected inlineMarkers()
 

Returns a map of inline markers to the corresponding parser methods.

This array defines handler methods for inline markdown markers.
When a marker is found in the text, the handler method is called with the text
starting at the position of the marker.

Note that markers starting with whitespace may slow down the parser,
you may want to use [[renderText]] to deal with them.

You may override this method to define a set of markers and parsing methods.
The default implementation looks for protected methods starting with parse that
also have an @marker annotation in PHPDoc.

protected parseBlock( $lines, $current)
 

Parses the block at current line by identifying the block type and parsing the content

protected parseBlocks( $lines)
 

Parse block elements by calling detectLineType() to identify them
and call consume function afterwards.

protected parseEscape( $text)
 

Parses escaped special characters.

  • marker \
protected parseInline( $text)
 

Parses inline elements of the language.

protected prepare()
 

This method will be called before parse() and parseParagraph().

You can override it to do some initialization work.

protected prepareMarkers( $text)
 

Prepare markers that are used in the text to parse

Add all markers that are present in markdown.
Check is done to avoid iterations in parseInline(), good for huge markdown files

protected renderAbsy( $blocks)
protected renderParagraph( $block)
 

Render a paragraph block

protected renderText( $block)
 

This function renders plain text sections in the markdown text.

It can be used to work on normal text sections for example to highlight keywords or
do special escaping.

Properties
private $_blockTypes
private $_depth
private $_inlineMarkers
 
© 2023 Bruce Wells
Search Namespaces \ Classes
Configuration