PHP Класс WPCom_GHF_Markdown_Parser, jetpack

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

Открытые свойства

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

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

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