PHP Класс Markdownify\Converter

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
_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
  • tags
  • handleTag_ol ( ) : void handle
      tags
    handleTag_p ( ) : void handle

    tags

    handleTag_pre ( ) : void handle
     tags    
    handleTag_strong ( ) : void handle and tags
    handleTag_ul ( ) : void handle
      tags
    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

    Описание методов

    __construct() публичный метод

    constructor, set options, setup parser
    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)
    Результат void

    _decode_hex() защищенный метод

    callback for decode() which converts a hexadecimal entity to UTF-8
    protected _decode_hex ( array $matches ) : string
    $matches array
    Результат string UTF-8 encoded

    _decode_numeric() защищенный метод

    callback for decode() which converts a numerical entity to UTF-8
    protected _decode_numeric ( array $matches ) : string
    $matches array
    Результат string UTF-8 encoded

    buffer() защищенный метод

    buffer next parser output until unbuffer() is called
    protected buffer ( ) : void
    Результат void

    decode() защищенный метод

    decode email addresses
    protected decode ( $text, $quote_style = ENT_QUOTES )

    fixBlockElementSpacing() защищенный метод

    Trims whitespace in block-level elements, on the left side.
    protected fixBlockElementSpacing ( )

    fixInlineElementSpacing() защищенный метод

    Examples: * leading: Text becomes Text * trailing: Text becomes Text
    protected fixInlineElementSpacing ( )

    flushFootnotes() защищенный метод

    output footnotes
    protected flushFootnotes ( ) : void
    Результат void

    flushLinebreaks() защищенный метод

    flush enqued linebreaks
    protected flushLinebreaks ( ) : void
    Результат void

    getLinkReference() защищенный метод

    return formated link reference
    protected getLinkReference ( array $tag ) : string
    $tag array
    Результат string link reference

    getStacked() защищенный метод

    get last stacked element of type $tagName
    protected getStacked ( string $tagName ) : array
    $tagName string
    Результат array

    handleHeader() защищенный метод

    handle header tags (

    -

    )
    protected handleHeader ( integer $level ) : void
    $level integer 1-6
    Результат void

    handleTagToText() защищенный метод

    handle non Markdownable tags
    protected handleTagToText ( ) : void
    Результат void

    handleTag_blockquote() защищенный метод

    handle
    tags
    protected handleTag_blockquote ( ) : void
    Результат void

    handleTag_br() защищенный метод

    handle
    tags
    protected handleTag_br ( ) : void
    Результат void

    handleTag_code() защищенный метод

    handle tags
    protected handleTag_code ( ) : void
    Результат void

    handleTag_em() защищенный метод

    handle and tags
    protected handleTag_em ( ) : void
    Результат void

    handleTag_h1() защищенный метод

    handle

    tags

    protected handleTag_h1 ( ) : void
    Результат void

    handleTag_h2() защищенный метод

    handle

    tags

    protected handleTag_h2 ( ) : void
    Результат void

    handleTag_h3() защищенный метод

    handle

    tags

    protected handleTag_h3 ( ) : void
    Результат void

    handleTag_h4() защищенный метод

    handle

    tags

    protected handleTag_h4 ( ) : void
    Результат void

    handleTag_h5() защищенный метод

    handle
    tags
    protected handleTag_h5 ( ) : void
    Результат void

    handleTag_h6() защищенный метод

    handle
    tags
    protected handleTag_h6 ( ) : void
    Результат void

    handleTag_hr() защищенный метод

    handle
    tags
    protected handleTag_hr ( ) : void
    Результат void

    handleTag_i() защищенный метод

    protected handleTag_i ( )

    handleTag_img() защищенный метод

    handle tags
    protected handleTag_img ( ) : void
    Результат void

    handleTag_li() защищенный метод

    handle
  • tags
  • protected handleTag_li ( ) : void
    Результат void

    handleTag_ol() защищенный метод

    handle
      tags
    protected handleTag_ol ( ) : void
    Результат void

    handleTag_p() защищенный метод

    handle

    tags

    protected handleTag_p ( ) : void
    Результат void

    handleTag_pre() защищенный метод

    handle
     tags        
    protected handleTag_pre ( ) : void
    Результат void

    handleTag_strong() защищенный метод

    handle and tags
    protected handleTag_strong ( ) : void
    Результат void

    handleTag_ul() защищенный метод

    handle
      tags
    protected handleTag_ul ( ) : void
    Результат void

    handleText() защищенный метод

    handle plain text
    protected handleText ( ) : void
    Результат void

    hasParent() защищенный метод

    check if current node has a $tagName as parent (somewhere, not only the direct parent)
    protected hasParent ( string $tagName ) : boolean
    $tagName string
    Результат boolean

    indent() защищенный метод

    indent next output (start tag) or unindent (end tag)
    protected indent ( string $str, boolean $output = true ) : void
    $str string indentation
    $output boolean add indendation to output
    Результат void

    isMarkdownable() защищенный метод

    check if current tag can be converted to Markdown
    protected isMarkdownable ( ) : boolean
    Результат boolean

    out() защищенный метод

    append string to the correct var, either directly to $this->output or to the current buffers
    protected out ( string $put, boolean $nowrap = false ) : void
    $put string
    $nowrap boolean
    Результат void

    parent() защищенный метод

    get tagName of direct parent tag
    protected parent ( ) : string
    Результат string $tagName

    parse() защищенный метод

    iterate through the nodes and decide what we shall do with the current node
    protected parse ( ) : void
    Результат void

    parseString() публичный метод

    parse a HTML string
    public parseString ( string $html ) : string
    $html string
    Результат string markdown formatted

    resetState() защищенный метод

    Ideal for running within a loop where you want to maintain a single instance.
    protected resetState ( )

    setKeepHTML() публичный метод

    set keep HTML tags which cannot be converted to markdown
    public setKeepHTML ( $keepHTML ) : void
    Результат void

    setLineBreaks() защищенный метод

    set number of line breaks before next start tag
    protected setLineBreaks ( integer $number ) : void
    $number integer
    Результат void

    setLinkPosition() публичный метод

    set the position where the link reference will be displayed
    public setLinkPosition ( integer $linkPosition ) : void
    $linkPosition integer
    Результат void

    stack() защищенный метод

    add current node to the stack this only stores the attributes
    protected stack ( ) : void
    Результат void

    strlen() защищенный метод

    UTF-8 strlen()
    protected strlen ( string $str ) : integer
    $str string
    Результат integer

    unbuffer() защищенный метод

    end current buffer and return buffered output
    protected unbuffer ( ) : string
    Результат string

    unichr() защищенный метод

    UTF-8 chr() which supports numeric entities
    protected unichr ( $dec ) : string
    Результат string UTF-8 encoded

    unstack() защищенный метод

    remove current tag from stack
    protected unstack ( ) : array
    Результат array

    wordwrap() защищенный метод

    wordwrap for utf8 encoded strings
    protected wordwrap ( string $str, $width, $break, $cut = false ) : string
    $str string
    Результат string

    Описание свойств

    $allowMixedChildren защищенное свойство

    html block tags that allow inline & block children
    protected array $allowMixedChildren
    Результат array

    $bodyWidth защищенное свойство

    wrap output, set to 0 to skip wrapping
    protected int $bodyWidth
    Результат integer

    $buffer защищенное свойство

    stores current buffers
    protected array $buffer
    Результат array

    $drop защищенное свойство

    html tags to be dropped (contents will not be parsed!)
    protected array $drop
    Результат array

    $escapeInText защищенное свойство

    list of chars which have to be escaped in normal text
    protected array $escapeInText
    Результат array

    $footnotes защищенное свойство

    stores current buffers
    protected array $footnotes
    Результат array

    $ignore защищенное свойство

    html tags to be ignored (contents will be parsed)
    protected array $ignore
    Результат array

    $indent защищенное свойство

    current indentation
    protected string $indent
    Результат string

    $isMarkdownable защищенное свойство

    tags with elements which can be handled by markdown
    protected array $isMarkdownable
    Результат array

    $keepHTML защищенное свойство

    keep html tags which cannot be converted to markdown
    protected bool $keepHTML
    Результат boolean

    $lastClosedTag защищенное свойство

    name of last closed tag
    protected string $lastClosedTag
    Результат string

    $lastWasBlockTag защищенное свойство

    wether last processed node was a block tag or not
    protected bool $lastWasBlockTag
    Результат boolean

    $lineBreaks защищенное свойство

    number of line breaks before next inline output
    protected $lineBreaks

    $linkPosition защищенное свойство

    position where the link reference will be displayed
    protected int $linkPosition
    Результат integer

    $minBodyWidth защищенное свойство

    minimum body width
    protected int $minBodyWidth
    Результат integer

    $notConverted защищенное свойство

    stack with tags which where not converted to html
    protected array $notConverted
    Результат array

    $output защищенное свойство

    markdown output
    protected string $output
    Результат string

    $parser защищенное свойство

    html parser object
    protected parseHTML $parser
    Результат parseHTML

    $skipConversion защищенное свойство

    skip conversion to markdown
    protected bool $skipConversion
    Результат boolean

    $stack защищенное свойство

    node stack, e.g. for and tags
    protected array $stack
    Результат array
    Markdown indents which could be wrapped
    protected array $wrappableIndents
    Результат array