PHP 클래스 Markdownify\Converter

파일 보기 프로젝트 열기: pixel418/markdownify 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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