|
|
|
@@ -3,7 +3,7 @@
|
|
|
|
|
# Markdown - A text-to-HTML conversion tool for web writers
|
|
|
|
|
#
|
|
|
|
|
# PHP Markdown
|
|
|
|
|
# Copyright (c) 2004-2013 Michel Fortin
|
|
|
|
|
# Copyright (c) 2004-2014 Michel Fortin
|
|
|
|
|
# <http://michelf.com/projects/php-markdown/>
|
|
|
|
|
#
|
|
|
|
|
# Original Markdown
|
|
|
|
@@ -21,7 +21,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
|
|
|
|
|
### Version ###
|
|
|
|
|
|
|
|
|
|
const MARKDOWNLIB_VERSION = "1.4.0";
|
|
|
|
|
const MARKDOWNLIB_VERSION = "1.4.1";
|
|
|
|
|
|
|
|
|
|
### Simple Function Interface ###
|
|
|
|
|
|
|
|
|
@@ -209,7 +209,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
)? # title is optional
|
|
|
|
|
(?:\n+|\Z)
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_stripLinkDefinitions_callback'),
|
|
|
|
|
array($this, '_stripLinkDefinitions_callback'),
|
|
|
|
|
$text);
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -242,7 +242,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
#
|
|
|
|
|
$block_tags_a_re = 'ins|del';
|
|
|
|
|
$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
|
|
|
|
|
'script|noscript|form|fieldset|iframe|math|svg|'.
|
|
|
|
|
'script|noscript|style|form|fieldset|iframe|math|svg|'.
|
|
|
|
|
'article|section|nav|aside|hgroup|header|footer|'.
|
|
|
|
|
'figure';
|
|
|
|
|
|
|
|
|
@@ -297,9 +297,9 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
# match will start at the first `<div>` and stop at the first `</div>`.
|
|
|
|
|
$text = preg_replace_callback('{(?>
|
|
|
|
|
(?>
|
|
|
|
|
(?<=\n\n) # Starting after a blank line
|
|
|
|
|
(?<=\n) # Starting on its own line
|
|
|
|
|
| # or
|
|
|
|
|
\A\n? # the beginning of the doc
|
|
|
|
|
\A\n? # the at beginning of the doc
|
|
|
|
|
)
|
|
|
|
|
( # save in $1
|
|
|
|
|
|
|
|
|
@@ -356,7 +356,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
)}Sxmi',
|
|
|
|
|
array(&$this, '_hashHTMLBlocks_callback'),
|
|
|
|
|
array($this, '_hashHTMLBlocks_callback'),
|
|
|
|
|
$text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
@@ -500,7 +500,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
protected function doHardBreaks($text) {
|
|
|
|
|
# Do hard breaks:
|
|
|
|
|
return preg_replace_callback('/ {2,}\n/',
|
|
|
|
|
array(&$this, '_doHardBreaks_callback'), $text);
|
|
|
|
|
array($this, '_doHardBreaks_callback'), $text);
|
|
|
|
|
}
|
|
|
|
|
protected function _doHardBreaks_callback($matches) {
|
|
|
|
|
return $this->hashPart("<br$this->empty_element_suffix\n");
|
|
|
|
@@ -531,7 +531,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
\]
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
array($this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Next, inline-style links: [link text](url "optional title")
|
|
|
|
@@ -558,7 +558,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
\)
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doAnchors_inline_callback'), $text);
|
|
|
|
|
array($this, '_doAnchors_inline_callback'), $text);
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Last, handle reference-style shortcuts: [link text]
|
|
|
|
@@ -572,7 +572,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
\]
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
array($this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
|
|
|
|
|
$this->in_anchor = false;
|
|
|
|
|
return $text;
|
|
|
|
@@ -617,6 +617,12 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
$url = $matches[3] == '' ? $matches[4] : $matches[3];
|
|
|
|
|
$title =& $matches[7];
|
|
|
|
|
|
|
|
|
|
// if the URL was of the form <s p a c e s> it got caught by the HTML
|
|
|
|
|
// tag parser and hashed. Need to reverse the process before using the URL.
|
|
|
|
|
$unhashed = $this->unhash($url);
|
|
|
|
|
if ($unhashed != $url)
|
|
|
|
|
$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
|
|
|
|
|
|
|
|
|
|
$url = $this->encodeAttribute($url);
|
|
|
|
|
|
|
|
|
|
$result = "<a href=\"$url\"";
|
|
|
|
@@ -654,7 +660,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doImages_reference_callback'), $text);
|
|
|
|
|
array($this, '_doImages_reference_callback'), $text);
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Next, handle inline images: 
|
|
|
|
@@ -683,7 +689,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
\)
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doImages_inline_callback'), $text);
|
|
|
|
|
array($this, '_doImages_inline_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -743,7 +749,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
# --------
|
|
|
|
|
#
|
|
|
|
|
$text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
|
|
|
|
|
array(&$this, '_doHeaders_callback_setext'), $text);
|
|
|
|
|
array($this, '_doHeaders_callback_setext'), $text);
|
|
|
|
|
|
|
|
|
|
# atx-style headers:
|
|
|
|
|
# # Header 1
|
|
|
|
@@ -760,7 +766,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
\#* # optional closing #\'s (not counted)
|
|
|
|
|
\n+
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_doHeaders_callback_atx'), $text);
|
|
|
|
|
array($this, '_doHeaders_callback_atx'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -789,7 +795,6 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
# Re-usable patterns to match list item bullets and number markers:
|
|
|
|
|
$marker_ul_re = '[*+-]';
|
|
|
|
|
$marker_ol_re = '\d+[\.]';
|
|
|
|
|
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
|
|
|
|
|
|
|
|
|
|
$markers_relist = array(
|
|
|
|
|
$marker_ul_re => $marker_ol_re,
|
|
|
|
@@ -833,14 +838,14 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
^
|
|
|
|
|
'.$whole_list_re.'
|
|
|
|
|
}mx',
|
|
|
|
|
array(&$this, '_doLists_callback'), $text);
|
|
|
|
|
array($this, '_doLists_callback'), $text);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$text = preg_replace_callback('{
|
|
|
|
|
(?:(?<=\n)\n|\A\n?) # Must eat the newline
|
|
|
|
|
'.$whole_list_re.'
|
|
|
|
|
}mx',
|
|
|
|
|
array(&$this, '_doLists_callback'), $text);
|
|
|
|
|
array($this, '_doLists_callback'), $text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -907,7 +912,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
(?:(\n+(?=\n))|\n) # tailing blank line = $5
|
|
|
|
|
(?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_processListItems_callback'), $list_str);
|
|
|
|
|
array($this, '_processListItems_callback'), $list_str);
|
|
|
|
|
|
|
|
|
|
$this->list_level--;
|
|
|
|
|
return $list_str;
|
|
|
|
@@ -951,7 +956,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
)
|
|
|
|
|
((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_doCodeBlocks_callback'), $text);
|
|
|
|
|
array($this, '_doCodeBlocks_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -979,19 +984,19 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $em_relist = array(
|
|
|
|
|
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
|
|
|
|
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
|
|
|
|
'_' => '(?<=\S|^)(?<!_)_(?!_)',
|
|
|
|
|
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?![\.,:;]?\s)',
|
|
|
|
|
'*' => '(?<![\s*])\*(?!\*)',
|
|
|
|
|
'_' => '(?<![\s_])_(?!_)',
|
|
|
|
|
);
|
|
|
|
|
protected $strong_relist = array(
|
|
|
|
|
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
|
|
|
|
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
|
|
|
|
'__' => '(?<=\S|^)(?<!_)__(?!_)',
|
|
|
|
|
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?![\.,:;]?\s)',
|
|
|
|
|
'**' => '(?<![\s*])\*\*(?!\*)',
|
|
|
|
|
'__' => '(?<![\s_])__(?!_)',
|
|
|
|
|
);
|
|
|
|
|
protected $em_strong_relist = array(
|
|
|
|
|
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
|
|
|
|
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
|
|
|
|
'___' => '(?<=\S|^)(?<!_)___(?!_)',
|
|
|
|
|
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?![\.,:;]?\s)',
|
|
|
|
|
'***' => '(?<![\s*])\*\*\*(?!\*)',
|
|
|
|
|
'___' => '(?<![\s_])___(?!_)',
|
|
|
|
|
);
|
|
|
|
|
protected $em_strong_prepared_relist;
|
|
|
|
|
|
|
|
|
@@ -1151,7 +1156,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
)+
|
|
|
|
|
)
|
|
|
|
|
/xm',
|
|
|
|
|
array(&$this, '_doBlockQuotes_callback'), $text);
|
|
|
|
|
array($this, '_doBlockQuotes_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -1165,7 +1170,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
# These leading spaces cause problem with <pre> content,
|
|
|
|
|
# so we need to fix that:
|
|
|
|
|
$bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
|
|
|
|
|
array(&$this, '_doBlockQuotes_callback2'), $bq);
|
|
|
|
|
array($this, '_doBlockQuotes_callback2'), $bq);
|
|
|
|
|
|
|
|
|
|
return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
|
|
|
|
|
}
|
|
|
|
@@ -1280,7 +1285,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
|
|
|
|
|
protected function doAutoLinks($text) {
|
|
|
|
|
$text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i',
|
|
|
|
|
array(&$this, '_doAutoLinks_url_callback'), $text);
|
|
|
|
|
array($this, '_doAutoLinks_url_callback'), $text);
|
|
|
|
|
|
|
|
|
|
# Email addresses: <[email protected]>
|
|
|
|
|
$text = preg_replace_callback('{
|
|
|
|
@@ -1301,8 +1306,8 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
)
|
|
|
|
|
>
|
|
|
|
|
}xi',
|
|
|
|
|
array(&$this, '_doAutoLinks_email_callback'), $text);
|
|
|
|
|
$text = preg_replace_callback('{<(tel:([^\'">\s]+))>}i',array(&$this, '_doAutoLinks_tel_callback'), $text);
|
|
|
|
|
array($this, '_doAutoLinks_email_callback'), $text);
|
|
|
|
|
$text = preg_replace_callback('{<(tel:([^\'">\s]+))>}i',array($this, '_doAutoLinks_tel_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -1351,7 +1356,8 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
$r = ($seed * (1 + $key)) % 100; # Pseudo-random function.
|
|
|
|
|
# roughly 10% raw, 45% hex, 45% dec
|
|
|
|
|
# '@' *must* be encoded. I insist.
|
|
|
|
|
if ($r > 90 && $char != '@') /* do nothing */;
|
|
|
|
|
# '"' has to be encoded inside the attribute
|
|
|
|
|
if ($r > 90 && $char != '@' && $char != '"') /* do nothing */;
|
|
|
|
|
else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';';
|
|
|
|
|
else $chars[$key] = '&#'.$ord.';';
|
|
|
|
|
}
|
|
|
|
@@ -1470,7 +1476,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
# appropriate number of space between each blocks.
|
|
|
|
|
|
|
|
|
|
$text = preg_replace_callback('/^.*\t.*$/m',
|
|
|
|
|
array(&$this, '_detab_callback'), $text);
|
|
|
|
|
array($this, '_detab_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -1510,7 +1516,7 @@ class Markdown implements MarkdownInterface {
|
|
|
|
|
# Swap back in all the tags hashed by _HashHTMLBlocks.
|
|
|
|
|
#
|
|
|
|
|
return preg_replace_callback('/(.)\x1A[0-9]+\1/',
|
|
|
|
|
array(&$this, '_unhash_callback'), $text);
|
|
|
|
|
array($this, '_unhash_callback'), $text);
|
|
|
|
|
}
|
|
|
|
|
protected function _unhash_callback($matches) {
|
|
|
|
|
return $this->html_hashes[$matches[0]];
|
|
|
|
@@ -1716,7 +1722,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
(?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr
|
|
|
|
|
(?:\n+|\Z)
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_stripLinkDefinitions_callback'),
|
|
|
|
|
array($this, '_stripLinkDefinitions_callback'),
|
|
|
|
|
$text);
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -1733,17 +1739,17 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
### HTML Block Parser ###
|
|
|
|
|
|
|
|
|
|
# Tags that are always treated as block tags:
|
|
|
|
|
protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption';
|
|
|
|
|
protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|figure';
|
|
|
|
|
|
|
|
|
|
# Tags treated as block tags only if the opening tag is alone on its line:
|
|
|
|
|
protected $context_block_tags_re = 'script|noscript|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
|
|
|
|
protected $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
|
|
|
|
|
|
|
|
|
# Tags where markdown="1" default to span mode:
|
|
|
|
|
protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
|
|
|
|
|
|
|
|
|
|
# Tags which must not have their contents modified, no matter where
|
|
|
|
|
# they appear:
|
|
|
|
|
protected $clean_tags_re = 'script|math|svg';
|
|
|
|
|
protected $clean_tags_re = 'script|style|math|svg';
|
|
|
|
|
|
|
|
|
|
# Tags that do not need to be closed.
|
|
|
|
|
protected $auto_close_tags_re = 'hr|img|param|source|track';
|
|
|
|
@@ -2227,7 +2233,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
\]
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
array($this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Next, inline-style links: [link text](url "optional title")
|
|
|
|
@@ -2255,7 +2261,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
(?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doAnchors_inline_callback'), $text);
|
|
|
|
|
array($this, '_doAnchors_inline_callback'), $text);
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Last, handle reference-style shortcuts: [link text]
|
|
|
|
@@ -2269,7 +2275,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
\]
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
array($this, '_doAnchors_reference_callback'), $text);
|
|
|
|
|
|
|
|
|
|
$this->in_anchor = false;
|
|
|
|
|
return $text;
|
|
|
|
@@ -2317,6 +2323,11 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
$title =& $matches[7];
|
|
|
|
|
$attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
|
|
|
|
|
|
|
|
|
|
// if the URL was of the form <s p a c e s> it got caught by the HTML
|
|
|
|
|
// tag parser and hashed. Need to reverse the process before using the URL.
|
|
|
|
|
$unhashed = $this->unhash($url);
|
|
|
|
|
if ($unhashed != $url)
|
|
|
|
|
$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
|
|
|
|
|
|
|
|
|
|
$url = $this->encodeAttribute($url);
|
|
|
|
|
|
|
|
|
@@ -2356,7 +2367,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doImages_reference_callback'), $text);
|
|
|
|
|
array($this, '_doImages_reference_callback'), $text);
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Next, handle inline images: 
|
|
|
|
@@ -2386,7 +2397,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
(?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
|
|
|
|
|
)
|
|
|
|
|
}xs',
|
|
|
|
|
array(&$this, '_doImages_inline_callback'), $text);
|
|
|
|
|
array($this, '_doImages_inline_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -2458,7 +2469,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
(?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes
|
|
|
|
|
[ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer
|
|
|
|
|
}mx',
|
|
|
|
|
array(&$this, '_doHeaders_callback_setext'), $text);
|
|
|
|
|
array($this, '_doHeaders_callback_setext'), $text);
|
|
|
|
|
|
|
|
|
|
# atx-style headers:
|
|
|
|
|
# # Header 1 {#header1}
|
|
|
|
@@ -2477,7 +2488,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
[ ]*
|
|
|
|
|
\n+
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_doHeaders_callback_atx'), $text);
|
|
|
|
|
array($this, '_doHeaders_callback_atx'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -2528,7 +2539,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
)
|
|
|
|
|
(?=\n|\Z) # Stop at final double newline.
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_doTable_leadingPipe_callback'), $text);
|
|
|
|
|
array($this, '_doTable_leadingPipe_callback'), $text);
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Find tables without leading pipe.
|
|
|
|
@@ -2554,7 +2565,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
)
|
|
|
|
|
(?=\n|\Z) # Stop at final double newline.
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_DoTable_callback'), $text);
|
|
|
|
|
array($this, '_DoTable_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -2678,7 +2689,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
(?>\A\n?|(?<=\n\n))
|
|
|
|
|
'.$whole_list_re.'
|
|
|
|
|
}mx',
|
|
|
|
|
array(&$this, '_doDefLists_callback'), $text);
|
|
|
|
|
array($this, '_doDefLists_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -2716,7 +2727,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
(?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed
|
|
|
|
|
# with a definition mark.
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_processDefListItems_callback_dt'), $list_str);
|
|
|
|
|
array($this, '_processDefListItems_callback_dt'), $list_str);
|
|
|
|
|
|
|
|
|
|
# Process actual definitions.
|
|
|
|
|
$list_str = preg_replace_callback('{
|
|
|
|
@@ -2733,7 +2744,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_processDefListItems_callback_dd'), $list_str);
|
|
|
|
|
array($this, '_processDefListItems_callback_dd'), $list_str);
|
|
|
|
|
|
|
|
|
|
return $list_str;
|
|
|
|
|
}
|
|
|
|
@@ -2801,7 +2812,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
# Closing marker.
|
|
|
|
|
\1 [ ]* (?= \n )
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_doFencedCodeBlocks_callback'), $text);
|
|
|
|
|
array($this, '_doFencedCodeBlocks_callback'), $text);
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -2811,7 +2822,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
$codeblock = $matches[4];
|
|
|
|
|
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
|
|
|
|
|
$codeblock = preg_replace_callback('/^\n+/',
|
|
|
|
|
array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock);
|
|
|
|
|
array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
|
|
|
|
|
|
|
|
|
|
if ($classname != "") {
|
|
|
|
|
if ($classname{0} == '.')
|
|
|
|
@@ -2837,19 +2848,19 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
# work in the middle of a word.
|
|
|
|
|
#
|
|
|
|
|
protected $em_relist = array(
|
|
|
|
|
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
|
|
|
|
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
|
|
|
|
'_' => '(?<=\S|^)(?<!_)_(?![a-zA-Z0-9_])',
|
|
|
|
|
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?![\.,:;]?\s)',
|
|
|
|
|
'*' => '(?<![\s*])\*(?!\*)',
|
|
|
|
|
'_' => '(?<![\s_])_(?![a-zA-Z0-9_])',
|
|
|
|
|
);
|
|
|
|
|
protected $strong_relist = array(
|
|
|
|
|
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
|
|
|
|
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
|
|
|
|
'__' => '(?<=\S|^)(?<!_)__(?![a-zA-Z0-9_])',
|
|
|
|
|
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?![\.,:;]?\s)',
|
|
|
|
|
'**' => '(?<![\s*])\*\*(?!\*)',
|
|
|
|
|
'__' => '(?<![\s_])__(?![a-zA-Z0-9_])',
|
|
|
|
|
);
|
|
|
|
|
protected $em_strong_relist = array(
|
|
|
|
|
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
|
|
|
|
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
|
|
|
|
'___' => '(?<=\S|^)(?<!_)___(?![a-zA-Z0-9_])',
|
|
|
|
|
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?![\.,:;]?\s)',
|
|
|
|
|
'***' => '(?<![\s*])\*\*\*(?!\*)',
|
|
|
|
|
'___' => '(?<![\s_])___(?![a-zA-Z0-9_])',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2908,13 +2919,13 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
.+ # actual text
|
|
|
|
|
|
|
|
|
|
|
\n # newlines but
|
|
|
|
|
(?!\[\^.+?\]:\s)# negative lookahead for footnote marker.
|
|
|
|
|
(?!\[.+?\][ ]?:\s)# negative lookahead for footnote or link definition marker.
|
|
|
|
|
(?!\n+[ ]{0,3}\S)# ensure line is not blank and followed
|
|
|
|
|
# by non-indented content
|
|
|
|
|
)*
|
|
|
|
|
)
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_stripFootnotes_callback'),
|
|
|
|
|
array($this, '_stripFootnotes_callback'),
|
|
|
|
|
$text);
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -2942,7 +2953,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
# Append footnote list to text.
|
|
|
|
|
#
|
|
|
|
|
$text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
|
|
|
|
|
array(&$this, '_appendFootnotes_callback'), $text);
|
|
|
|
|
array($this, '_appendFootnotes_callback'), $text);
|
|
|
|
|
|
|
|
|
|
if (!empty($this->footnotes_ordered)) {
|
|
|
|
|
$text .= "\n\n";
|
|
|
|
@@ -2974,7 +2985,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
$footnote .= "\n"; # Need to append newline before parsing.
|
|
|
|
|
$footnote = $this->runBlockGamut("$footnote\n");
|
|
|
|
|
$footnote = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
|
|
|
|
|
array(&$this, '_appendFootnotes_callback'), $footnote);
|
|
|
|
|
array($this, '_appendFootnotes_callback'), $footnote);
|
|
|
|
|
|
|
|
|
|
$attr = str_replace("%%", ++$num, $attr);
|
|
|
|
|
$note_id = $this->encodeAttribute($note_id);
|
|
|
|
@@ -3057,7 +3068,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1
|
|
|
|
|
(.*) # text = $2 (no blank lines allowed)
|
|
|
|
|
}xm',
|
|
|
|
|
array(&$this, '_stripAbbreviations_callback'),
|
|
|
|
|
array($this, '_stripAbbreviations_callback'),
|
|
|
|
|
$text);
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
@@ -3084,7 +3095,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|
|
|
|
'(?:'.$this->abbr_word_re.')'.
|
|
|
|
|
'(?![\w\x1A])'.
|
|
|
|
|
'}',
|
|
|
|
|
array(&$this, '_doAbbreviations_callback'), $text);
|
|
|
|
|
array($this, '_doAbbreviations_callback'), $text);
|
|
|
|
|
}
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|