PHP 클래스 WPCom_GHF_Markdown_Parser, jetpack

상속: extends MarkdownExtra_Parser
파일 보기 프로젝트 열기: automattic/jetpack 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$preserve_inline_code_blocks boolean Preserve single-line blocks.
$preserve_latex Preserve the legacy $latex your-latex-code-here$ style LaTeX markup
$preserve_shortcodes boolean This requires use within a WordPress installation.
$shortcode_end
$shortcode_start Will run through sprintf - you can supply your own syntax if you want
$strip_paras boolean Strip paragraphs from the output. This is the right default for WordPress, which generally wants to create its own paragraphs with wpautop
$use_code_shortcode boolean Use a [code] shortcode when encountering a fenced code block

보호된 프로퍼티들

프로퍼티 타입 설명
$preserve_text_hash Stores shortcodes we remove and then replace

공개 메소드들

메소드 설명
__construct ( ) Set environment defaults based on presence of key functions/classes.
_doEscapeForHashWithoutSpacing ( array $m ) : string Callback for pre-processing start of line hashes to slyly escape headings that don't have a leading space
_doFencedCodeBlocks_callback ( $matches ) Overload to support Viper's [code] shortcode. Because awesome.
codeblock_preserve ( string $text ) : string Preserve code block contents by HTML encoding them. Useful before getting to KSES stripping.
codeblock_restore ( string $text ) : string Restore previously preserved (i.e. escaped) code block contents.
doFencedCodeBlocks ( $text ) Overload to support ```-fenced code blocks for pre-Markdown Extra 1.2.8 https://help.github.com/articles/github-flavored-markdown#fenced-code-blocks
do_codeblock_preserve ( array $matches ) : string Regex callback for code block preservation.
do_codeblock_restore ( array $matches ) : string Regex callback for code block restoration (unescaping).
do_single_line_code_preserve ( array $matches ) : string Regex callback for inline code presevation
single_line_code_preserve ( string $text ) : string Prevents blocks like __this__ from turning into this
transform ( string $text ) : string Overload to specify heading styles only if the hash has space(s) after it. This is actually in keeping with the documentation and eases the semantic overload of the hash character.
unp ( string $text ) : string Remove bare

elements.

s with attributes will be preserved.

보호된 메소드들

메소드 설명
_doRemoveText ( array $m ) : string Regex callback for text preservation
do_restore ( string $text ) : string Restores any text preserved by $this->hash_block()
get_shortcode_regex ( ) : string A regex of all shortcodes currently registered by the current WordPress installation
hash_block ( string $text ) : string Call this to store a text block for later restoration.
hash_maker ( string $hash ) : string Less glamorous than the Keymaker
latex_preserve ( string $text ) : string Called to preserve legacy LaTeX like $latex some-latex-text $
restore_leading_hash ( string $text ) : string Since we escape unspaced #Headings, put things back later.
shortcode_preserve ( string $text ) : string Called to preserve WP shortcodes from being formatted by Markdown in any way.

메소드 상세

__construct() 공개 메소드

Set environment defaults based on presence of key functions/classes.
public __construct ( )

_doEscapeForHashWithoutSpacing() 공개 메소드

Callback for pre-processing start of line hashes to slyly escape headings that don't have a leading space
public _doEscapeForHashWithoutSpacing ( array $m ) : string
$m array preg_match matches
리턴 string possibly escaped start of line hash

_doFencedCodeBlocks_callback() 공개 메소드

Overload to support Viper's [code] shortcode. Because awesome.
public _doFencedCodeBlocks_callback ( $matches )

_doRemoveText() 보호된 메소드

Regex callback for text preservation
protected _doRemoveText ( array $m ) : string
$m array Regex $matches array
리턴 string A placeholder that will later be replaced by the original text

codeblock_preserve() 공개 메소드

Preserve code block contents by HTML encoding them. Useful before getting to KSES stripping.
public codeblock_preserve ( string $text ) : string
$text string Markdown/HTML content
리턴 string Markdown/HTML content with escaped code blocks

codeblock_restore() 공개 메소드

Restore previously preserved (i.e. escaped) code block contents.
public codeblock_restore ( string $text ) : string
$text string Markdown/HTML content with escaped code blocks
리턴 string Markdown/HTML content

doFencedCodeBlocks() 공개 메소드

Overload to support ```-fenced code blocks for pre-Markdown Extra 1.2.8 https://help.github.com/articles/github-flavored-markdown#fenced-code-blocks
public doFencedCodeBlocks ( $text )

do_codeblock_preserve() 공개 메소드

Regex callback for code block preservation.
public do_codeblock_preserve ( array $matches ) : string
$matches array Regex matches
리턴 string Codeblock with escaped interior

do_codeblock_restore() 공개 메소드

Regex callback for code block restoration (unescaping).
public do_codeblock_restore ( array $matches ) : string
$matches array Regex matches
리턴 string Codeblock with unescaped interior

do_restore() 보호된 메소드

Restores any text preserved by $this->hash_block()
protected do_restore ( string $text ) : string
$text string Text that may have hashed preservation placeholders
리턴 string Text with hashed preseravtion placeholders replaced by original text

do_single_line_code_preserve() 공개 메소드

Regex callback for inline code presevation
public do_single_line_code_preserve ( array $matches ) : string
$matches array Regex matches
리턴 string Hashed content for later restoration

get_shortcode_regex() 보호된 메소드

A regex of all shortcodes currently registered by the current WordPress installation
protected get_shortcode_regex ( ) : string
리턴 string A regex for grabbing shortcodes.

hash_block() 보호된 메소드

Call this to store a text block for later restoration.
protected hash_block ( string $text ) : string
$text string Text to preserve for later
리턴 string Placeholder that will be swapped out later for the original text

hash_maker() 보호된 메소드

Less glamorous than the Keymaker
protected hash_maker ( string $hash ) : string
$hash string An md5 hash
리턴 string A placeholder hash

latex_preserve() 보호된 메소드

Called to preserve legacy LaTeX like $latex some-latex-text $
protected latex_preserve ( string $text ) : string
$text string Text in which to preserve LaTeX
리턴 string Text with LaTeX replaced by a hash that will be restored later

restore_leading_hash() 보호된 메소드

Since we escape unspaced #Headings, put things back later.
protected restore_leading_hash ( string $text ) : string
$text string text with a leading escaped hash
리턴 string text with leading hashes unescaped

shortcode_preserve() 보호된 메소드

Called to preserve WP shortcodes from being formatted by Markdown in any way.
protected shortcode_preserve ( string $text ) : string
$text string Text in which to preserve shortcodes
리턴 string Text with shortcodes replaced by a hash that will be restored later

single_line_code_preserve() 공개 메소드

Prevents blocks like __this__ from turning into this
public single_line_code_preserve ( string $text ) : string
$text string Text that may need preserving
리턴 string Text that was preserved if needed

transform() 공개 메소드

#Will Not Produce a Heading 1 # This Will Produce a Heading 1
public transform ( string $text ) : string
$text string Markdown text
리턴 string HTML-transformed text

unp() 공개 메소드

Remove bare

elements.

s with attributes will be preserved.

public unp ( string $text ) : string
$text string HTML content
리턴 string

-less content

프로퍼티 상세

$preserve_inline_code_blocks 공개적으로 프로퍼티

Preserve single-line blocks.
public bool $preserve_inline_code_blocks
리턴 boolean

$preserve_latex 공개적으로 프로퍼티

Preserve the legacy $latex your-latex-code-here$ style LaTeX markup
public $preserve_latex

$preserve_shortcodes 공개적으로 프로퍼티

This requires use within a WordPress installation.
public bool $preserve_shortcodes
리턴 boolean

$preserve_text_hash 보호되어 있는 프로퍼티

Stores shortcodes we remove and then replace
protected $preserve_text_hash

$shortcode_end 공개적으로 프로퍼티

public $shortcode_end

$shortcode_start 공개적으로 프로퍼티

Will run through sprintf - you can supply your own syntax if you want
public $shortcode_start

$strip_paras 공개적으로 프로퍼티

Strip paragraphs from the output. This is the right default for WordPress, which generally wants to create its own paragraphs with wpautop
public bool $strip_paras
리턴 boolean

$use_code_shortcode 공개적으로 프로퍼티

Use a [code] shortcode when encountering a fenced code block
public bool $use_code_shortcode
리턴 boolean