Property | Type | Description | |
---|---|---|---|
$allowMixedChildren | array |
html block tags that allow inline & block children | |
$bodyWidth | integer | wrap output, set to 0 to skip wrapping | |
$buffer | array |
stores current buffers | |
$drop | array |
html tags to be dropped (contents will not be parsed!) | |
$escapeInText | array | list of chars which have to be escaped in normal text | |
$footnotes | array |
stores current buffers | |
$ignore | array |
html tags to be ignored (contents will be parsed) | |
$indent | string | current indentation | |
$isMarkdownable | array |
tags with elements which can be handled by markdown | |
$keepHTML | boolean | keep html tags which cannot be converted to markdown | |
$lastClosedTag | string | name of last closed tag | |
$lastWasBlockTag | boolean | wether last processed node was a block tag or not | |
$lineBreaks | number of line breaks before next inline output | ||
$linkPosition | integer | position where the link reference will be displayed | |
$minBodyWidth | integer | minimum body width | |
$notConverted | array |
stack with tags which where not converted to html | |
$output | string | markdown output | |
$parser | parseHTML | html parser object | |
$skipConversion | boolean | skip conversion to markdown | |
$stack | array |
node stack, e.g. for and tags | |
$wrappableIndents | array |
Markdown indents which could be wrapped |
Method | Description | |
---|---|---|
__construct ( integer $linkPosition = self::LINK_AFTER_CONTENT, integer $bodyWidth = MDFY_BODYWIDTH, boolean $keepHTML = MDFY_KEEPHTML ) : void | constructor, set options, setup parser | |
parseString ( string $html ) : string | parse a HTML string | |
setKeepHTML ( $keepHTML ) : void | set keep HTML tags which cannot be converted to markdown | |
setLinkPosition ( integer $linkPosition ) : void | set the position where the link reference will be displayed |
Method | Description | |
---|---|---|
_decode_hex ( array $matches ) : string | callback for decode() which converts a hexadecimal entity to UTF-8 | |
_decode_numeric ( array $matches ) : string | callback for decode() which converts a numerical entity to UTF-8 | |
buffer ( ) : void | buffer next parser output until unbuffer() is called | |
decode ( $text, $quote_style = ENT_QUOTES ) | decode email addresses | |
fixBlockElementSpacing ( ) | Trims whitespace in block-level elements, on the left side. | |
fixInlineElementSpacing ( ) | Moves leading/trailing whitespace from inline elements outside of the element. This is to fix cases like Text, which if converted to ** strong** would be incorrect Markdown. | |
flushFootnotes ( ) : void | output footnotes | |
flushLinebreaks ( ) : void | flush enqued linebreaks | |
getLinkReference ( array $tag ) : string | return formated link reference | |
getStacked ( string $tagName ) : array | get last stacked element of type $tagName | |
handleHeader ( integer $level ) : void |
handle header tags (-) |
|
handleTagToText ( ) : void | handle non Markdownable tags | |
handleTag_a ( ) : void | handle tags | |
handleTag_a_converter ( array $tag, string $buffer ) : string | handle tags conversion | |
handleTag_a_parser ( ) : void | handle tags parsing | |
handleTag_b ( ) | ||
handleTag_blockquote ( ) : void |
handle tags |
|
handleTag_br ( ) : void |
handle tags |
|
handleTag_code ( ) : void |
handle tags |
|
handleTag_em ( ) : void | handle and tags | |
handleTag_h1 ( ) : void |
handle tags |
|
handleTag_h2 ( ) : void |
handle tags |
|
handleTag_h3 ( ) : void |
handle tags |
|
handleTag_h4 ( ) : void |
handle tags |
|
handleTag_h5 ( ) : void |
handle tags |
|
handleTag_h6 ( ) : void |
handle tags |
|
handleTag_hr ( ) : void |
handle tags |
|
handleTag_i ( ) | ||
handleTag_img ( ) : void | handle tags | |
handleTag_li ( ) : void |
handle |
|
handleTag_ol ( ) : void |
handle
|
|
handleTag_p ( ) : void |
handle tags |
|
handleTag_pre ( ) : void |
handle tags |
|
handleTag_strong ( ) : void | handle and tags | |
handleTag_ul ( ) : void |
handle
|
|
handleText ( ) : void | handle plain text | |
hasParent ( string $tagName ) : boolean | check if current node has a $tagName as parent (somewhere, not only the direct parent) | |
indent ( string $str, boolean $output = true ) : void | indent next output (start tag) or unindent (end tag) | |
isMarkdownable ( ) : boolean | check if current tag can be converted to Markdown | |
out ( string $put, boolean $nowrap = false ) : void | append string to the correct var, either directly to $this->output or to the current buffers | |
parent ( ) : string | get tagName of direct parent tag | |
parse ( ) : void | iterate through the nodes and decide what we shall do with the current node | |
resetState ( ) | Resetting the state forces the instance to behave as a fresh instance. | |
setLineBreaks ( integer $number ) : void | set number of line breaks before next start tag | |
stack ( ) : void | add current node to the stack this only stores the attributes | |
strlen ( string $str ) : integer | UTF-8 strlen() | |
unbuffer ( ) : string | end current buffer and return buffered output | |
unichr ( $dec ) : string | UTF-8 chr() which supports numeric entities | |
unstack ( ) : array | remove current tag from stack | |
wordwrap ( string $str, $width, $break, $cut = false ) : string | wordwrap for utf8 encoded strings |
public __construct ( integer $linkPosition = self::LINK_AFTER_CONTENT, integer $bodyWidth = MDFY_BODYWIDTH, boolean $keepHTML = MDFY_KEEPHTML ) : void | ||
$linkPosition | integer | define the position of links |
$bodyWidth | integer | whether or not to wrap the output to the given width defaults to false |
$keepHTML | boolean | whether to keep non markdownable HTML or to discard it defaults to true (HTML will be kept) |
return | void |
protected _decode_hex ( array $matches ) : string | ||
$matches | array | |
return | string | UTF-8 encoded |
protected _decode_numeric ( array $matches ) : string | ||
$matches | array | |
return | string | UTF-8 encoded |
protected decode ( $text, $quote_style = ENT_QUOTES ) |
protected fixBlockElementSpacing ( ) |
protected fixInlineElementSpacing ( ) |
protected flushLinebreaks ( ) : void | ||
return | void |
protected getLinkReference ( array $tag ) : string | ||
$tag | array | |
return | string | link reference |
protected getStacked ( string $tagName ) : array | ||
$tagName | string | |
return | array |
protected handleHeader ( integer $level ) : void | ||
$level | integer | 1-6 |
return | void |
protected handleTagToText ( ) : void | ||
return | void |
tags
protected handleTag_blockquote ( ) : void | ||
return | void |
handle and tags
protected handleTag_strong ( ) : void
return
void
check if current node has a $tagName as parent (somewhere, not only the direct parent)
indent next output (start tag) or unindent (end tag)
check if current tag can be converted to Markdown
protected isMarkdownable ( ) : boolean
return
boolean
append string to the correct var, either
directly to $this->output or to the current
buffers
get tagName of direct parent tag
iterate through the nodes and decide what we
shall do with the current node
parse a HTML string
public parseString ( string $html ) : string
$html
string
return
string
markdown formatted
Ideal for running within a loop where you want to maintain a single instance.
protected resetState ( )
set keep HTML tags which cannot be converted to markdown
public setKeepHTML ( $keepHTML ) : void
return
void
set number of line breaks before next start tag
protected setLineBreaks ( integer $number ) : void
$number
integer
return
void
set the position where the link reference will be displayed
public setLinkPosition ( integer $linkPosition ) : void
$linkPosition
integer
return
void
add current node to the stack
this only stores the attributes
UTF-8 strlen()
end current buffer and return buffered output
UTF-8 chr() which supports numeric entities
wordwrap for utf8 encoded strings
Property Details
html block tags that allow inline & block children
protected array $allowMixedChildren
return
array
wrap output, set to 0 to skip wrapping
protected int $bodyWidth
return
integer
html tags to be dropped (contents will not be parsed!)
protected array $drop
return
array
list of chars which have to be escaped in normal text
protected array $escapeInText
return
array
html tags to be ignored (contents will be parsed)
protected array $ignore
return
array
tags with elements which can be handled by markdown
protected array $isMarkdownable
return
array
keep html tags which cannot be converted to markdown
protected bool $keepHTML
return
boolean
name of last closed tag
protected string $lastClosedTag
return
string
wether last processed node was a block tag or not
protected bool $lastWasBlockTag
return
boolean
number of line breaks before next inline output
protected $lineBreaks
position where the link reference will be displayed
protected int $linkPosition
return
integer
stack with tags which where not converted to html
protected array $notConverted
return
array
skip conversion to markdown
protected bool $skipConversion
return
boolean