diff --git a/Parsedown.php b/Parsedown.php index 040b774..efb11dc 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -974,7 +974,7 @@ class Parsedown case '`': - if (preg_match('/^(`+)(.+?)\1(?!`)/', $text, $matches)) + if (preg_match('/^(`+)[ ]*(.+?)[ ]*\1(?!`)/', $text, $matches)) { $element_text = $matches[2]; $element_text = htmlspecialchars($element_text, ENT_NOQUOTES, 'UTF-8'); diff --git a/tests/data/code_span.html b/tests/data/code_span.html index 67b28b1..351610a 100644 --- a/tests/data/code_span.html +++ b/tests/data/code_span.html @@ -1,3 +1,5 @@

a code span

this is also a codespan trailing text

-

and look at this one!

\ No newline at end of file +

and look at this one!

+

single backtick in a code span: `

+

backtick-delimited string in a code span: `foo`

\ No newline at end of file diff --git a/tests/data/code_span.md b/tests/data/code_span.md index 3b850fd..0654262 100644 --- a/tests/data/code_span.md +++ b/tests/data/code_span.md @@ -2,4 +2,8 @@ a `code span` `this is also a codespan` trailing text -`and look at this one!` \ No newline at end of file +`and look at this one!` + +single backtick in a code span: `` ` `` + +backtick-delimited string in a code span: `` `foo` `` \ No newline at end of file