Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed problem with headers and horizontal rules within fenced code bl…

…ocks.
  • Loading branch information...
commit 34f521d4aa88c76a9cdf1048c104f127e0e39141 1 parent c10f487
@michelf authored
Showing with 12 additions and 7 deletions.
  1. +6 −0 PHP Markdown Extra Readme.text
  2. +6 −7 markdown.php
View
6 PHP Markdown Extra Readme.text
@@ -204,6 +204,12 @@ expected; (3) the output PHP Markdown actually produced.
Version History
---------------
+Current Extra:
+
+* Fixed a problem where Markdown headers and horizontal rules were
+ transformed into their HTML equivalent inside fenced code blocks.
+
+
Extra 1.2:
* Added fenced code block syntax which don't require indentation
View
13 markdown.php
@@ -1541,6 +1541,7 @@ function MarkdownExtra_Parser() {
"appendFootnotes" => 50,
);
$this->block_gamut += array(
+ "doFencedCodeBlocks" => 5,
"doTables" => 15,
"doDefLists" => 45,
);
@@ -2358,7 +2359,7 @@ function _processDefListItems_callback_dd($matches) {
}
- function doCodeBlocks($text) {
+ function doFencedCodeBlocks($text) {
#
# Adding the fenced code block syntax to regular Markdown:
#
@@ -2387,21 +2388,19 @@ function doCodeBlocks($text) {
# Closing marker.
\1 [ ]* \n
}xm',
- array(&$this, '_doCodeBlocks_fenced_callback'), $text);
-
- $text = parent::doCodeBlocks($text);
+ array(&$this, '_doFencedCodeBlocks_callback'), $text);
return $text;
}
- function _doCodeBlocks_fenced_callback($matches) {
+ function _doFencedCodeBlocks_callback($matches) {
$codeblock = $matches[2];
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
$codeblock = preg_replace_callback('/^\n+/',
- array(&$this, '_doCodeBlocks_fenced_newlines'), $codeblock);
+ array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock);
$codeblock = "<pre><code>$codeblock</code></pre>";
return "\n\n".$this->hashBlock($codeblock)."\n\n";
}
- function _doCodeBlocks_fenced_newlines($matches) {
+ function _doFencedCodeBlocks_newlines($matches) {
return str_repeat("<br$this->empty_element_suffix",
strlen($matches[0]));
}
Please sign in to comment.
Something went wrong with that request. Please try again.