PHP Class WPCom_GHF_Markdown_Parser, jetpack

Inheritance: extends MarkdownExtra_Parser
Afficher le fichier Open project: automattic/jetpack Class Usage Examples

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$preserve_text_hash Stores shortcodes we remove and then replace

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
_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.

Method Details

__construct() public méthode

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

_doEscapeForHashWithoutSpacing() public méthode

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
Résultat string possibly escaped start of line hash

_doFencedCodeBlocks_callback() public méthode

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

_doRemoveText() protected méthode

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

codeblock_preserve() public méthode

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
Résultat string Markdown/HTML content with escaped code blocks

codeblock_restore() public méthode

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

doFencedCodeBlocks() public méthode

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() public méthode

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

do_codeblock_restore() public méthode

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

do_restore() protected méthode

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

do_single_line_code_preserve() public méthode

Regex callback for inline code presevation
public do_single_line_code_preserve ( array $matches ) : string
$matches array Regex matches
Résultat string Hashed content for later restoration

get_shortcode_regex() protected méthode

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

hash_block() protected méthode

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

hash_maker() protected méthode

Less glamorous than the Keymaker
protected hash_maker ( string $hash ) : string
$hash string An md5 hash
Résultat string A placeholder hash

latex_preserve() protected méthode

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

restore_leading_hash() protected méthode

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

shortcode_preserve() protected méthode

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
Résultat string Text with shortcodes replaced by a hash that will be restored later

single_line_code_preserve() public méthode

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

transform() public méthode

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

unp() public méthode

Remove bare

elements.

s with attributes will be preserved.

public unp ( string $text ) : string
$text string HTML content
Résultat string

-less content

Property Details

$preserve_inline_code_blocks public_oe property

Preserve single-line blocks.
public bool $preserve_inline_code_blocks
Résultat boolean

$preserve_latex public_oe property

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

$preserve_shortcodes public_oe property

This requires use within a WordPress installation.
public bool $preserve_shortcodes
Résultat boolean

$preserve_text_hash protected_oe property

Stores shortcodes we remove and then replace
protected $preserve_text_hash

$shortcode_end public_oe property

public $shortcode_end

$shortcode_start public_oe property

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

$strip_paras public_oe property

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
Résultat boolean

$use_code_shortcode public_oe property

Use a [code] shortcode when encountering a fenced code block
public bool $use_code_shortcode
Résultat boolean