Improving GFM-Style Fenced Code Blocks; and Updating to data-lang="".

This commit is contained in:
Jason Caldwell 2013-09-30 22:58:34 -07:00
parent 2383db7cd6
commit 149e0dccc1

View file

@ -1846,7 +1846,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
# Fenced code block marker
(?<= ^ | \n )
[ ]{0,'.($indent+3).'}[`~]{3,}
[ ]{0,'.($indent+3).'}(?:~{3,}|`{3,})
[A-Za-z0-9_\-]* # Language (optional).
[ ]*
(?:
@ -1919,7 +1919,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
#
# Check for: Fenced code block marker.
#
else if (preg_match('{^\n?([ ]{0,'.($indent+3).'})([`~]+)}', $tag, $capture)) {
else if (preg_match('{^\n?([ ]{0,'.($indent+3).'})(~+|`+)}', $tag, $capture)) {
# Fenced code block marker: find matching end marker.
$fence_indent = strlen($capture[1]); # use captured indent in re
$fence_re = $capture[2]; # use captured fence in re
@ -2772,7 +2772,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
(?:\n|\A)
# 1: Opening marker
(
[`~]{3,} # 3 or more backticks/tildes.
(?:~{3,}|`{3,}) # 3 or more tildes/backticks.
)
# 2: Code language marker (optional).
(
@ -2811,7 +2811,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock);
$attr_str = ''; # Initialize string of attributes.
if($language != '') $attr_str .= ' lang="'.$language.'"';
if($language != '') $attr_str .= ' data-lang="'.$language.'"';
if ($classname != "") {
if ($classname{0} == '.')