diff options
author | Thomas Lange <code@nerdmind.de> | 2021-05-20 23:19:07 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-05-20 23:19:07 +0200 |
commit | 2c693b3aa1b5f256016a3316edffe8ce933bf05c (patch) | |
tree | fc4e30fa82c5a4b77da82a16bc4e01ef83ac90af | |
parent | 5a086214c96b1bfbe67505c3aa064695c18b5692 (diff) | |
download | blog-66dcc383fbf06b054bb4a25c507fa403487d5f54.tar.gz blog-66dcc383fbf06b054bb4a25c507fa403487d5f54.tar.xz blog-66dcc383fbf06b054bb4a25c507fa403487d5f54.zip |
Update Parsedown library to version 1.7.4v2.4.3
This commit updates the Parsedown library to version 1.7.4. The patch to
prevent tab indentations in code blocks from being converted to spaces
is already applied here.
See: 78c5974cd34559d0130d8be509935e2c992cd9ca
-rw-r--r-- | core/namespace/Parsedown.php | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/core/namespace/Parsedown.php b/core/namespace/Parsedown.php index e101bc5..51237b3 100644 --- a/core/namespace/Parsedown.php +++ b/core/namespace/Parsedown.php @@ -17,7 +17,7 @@ class Parsedown { # ~ - const version = '1.7.1'; + const version = '1.7.4'; # ~ @@ -418,7 +418,21 @@ class Parsedown if (isset($matches[1])) { - $class = 'language-'.$matches[1]; + /** + * https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes + * Every HTML element may have a class attribute specified. + * The attribute, if specified, must have a value that is a set + * of space-separated tokens representing the various classes + * that the element belongs to. + * [...] + * The space characters, for the purposes of this specification, + * are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), + * U+000A LINE FEED (LF), U+000C FORM FEED (FF), and + * U+000D CARRIAGE RETURN (CR). + */ + $language = substr($matches[1], 0, strcspn($matches[1], " \t\n\f\r")); + + $class = 'language-'.$language; $Element['attributes'] = array( 'class' => $class, @@ -1464,22 +1478,41 @@ class Parsedown } } + $permitRawHtml = false; + if (isset($Element['text'])) { + $text = $Element['text']; + } + // very strongly consider an alternative if you're writing an + // extension + elseif (isset($Element['rawHtml'])) + { + $text = $Element['rawHtml']; + $allowRawHtmlInSafeMode = isset($Element['allowRawHtmlInSafeMode']) && $Element['allowRawHtmlInSafeMode']; + $permitRawHtml = !$this->safeMode || $allowRawHtmlInSafeMode; + } + + if (isset($text)) + { $markup .= '>'; - if (!isset($Element['nonNestables'])) + if (!isset($Element['nonNestables'])) { $Element['nonNestables'] = array(); } if (isset($Element['handler'])) { - $markup .= $this->{$Element['handler']}($Element['text'], $Element['nonNestables']); + $markup .= $this->{$Element['handler']}($text, $Element['nonNestables']); + } + elseif (!$permitRawHtml) + { + $markup .= self::escape($text, true); } else { - $markup .= self::escape($Element['text'], true); + $markup .= $text; } $markup .= '</'.$Element['name'].'>'; |