Allow a single space in the code span delimiter

Fix #89 properly.
This commit is contained in:
Haralan Dobrev 2014-02-06 10:56:44 +02:00
parent 95e9878fb0
commit d25466fa8f
3 changed files with 16 additions and 4 deletions

View File

@ -1028,9 +1028,9 @@ class Parsedown
case '`': case '`':
if (preg_match('/^(`+)[ ]*(.+?)[ ]*\1(?!`)/', $text, $matches)) if (preg_match('/^(`+)([ ]?)(.+?)\2\1(?!`)/', $text, $matches))
{ {
$element_text = $matches[2]; $element_text = $matches[3];
$element_text = htmlspecialchars($element_text, ENT_NOQUOTES, 'UTF-8'); $element_text = htmlspecialchars($element_text, ENT_NOQUOTES, 'UTF-8');
$markup .= '<code>'.$element_text.'</code>'; $markup .= '<code>'.$element_text.'</code>';

View File

@ -3,3 +3,7 @@
<p><code>and look at this one!</code></p> <p><code>and look at this one!</code></p>
<p>single backtick in a code span: <code>`</code></p> <p>single backtick in a code span: <code>`</code></p>
<p>backtick-delimited string in a code span: <code>`foo`</code></p> <p>backtick-delimited string in a code span: <code>`foo`</code></p>
<p>Trim spaces: <code>code</code></p>
<p>Multiple spaces: <code> like that </code></p>
<p>Unequal number of spaces: <code> like that </code></p>
<p>Space only at the beginning: <code> code</code></p>

View File

@ -7,3 +7,11 @@ a `code span`
single backtick in a code span: `` ` `` single backtick in a code span: `` ` ``
backtick-delimited string in a code span: `` `foo` `` backtick-delimited string in a code span: `` `foo` ``
Trim spaces: `` code ``
Multiple spaces: `` like that ``
Unequal number of spaces: `` like that ``
Space only at the beginning: `` code``