1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Compare commits

...

4 Commits
0.9.2 ... 0.9.4

Author SHA1 Message Date
d29ff18299 resolve #92 2014-02-06 14:16:14 +02:00
95e9878fb0 improve tests 2014-02-06 02:37:09 +02:00
611aed179d simplify reference 2014-02-06 02:36:22 +02:00
abb88d59fa fix reference 2014-02-06 02:36:11 +02:00
7 changed files with 30 additions and 17 deletions

View File

@ -438,6 +438,11 @@ class Parsedown
$substring = substr($outdented_line, $position + 2);
$substring = trim($substring);
if ($substring === '')
{
break;
}
if ($substring[0] === '<')
{
$position = strpos($substring, '>');
@ -471,22 +476,19 @@ class Parsedown
if ($substring !== false)
{
if ($substring[0] !== '"' and $substring[0] !== "'" and $substring[0] !== '(')
{
break;
}
$last_char = substr($substring, -1);
switch (true)
if ($last_char !== '"' and $last_char !== "'" and $last_char !== ')')
{
case $substring[0] === '"' and $substring[0] === $last_char:
case $substring[0] === "'" and $substring[0] === $last_char:
case $substring[0] === '(' and $last_char === ')':
$reference['#'] = substr($substring, 1, -1);
break;
default:
break 2;
break;
}
$reference['#'] = substr($substring, 1, -1);
}
$this->reference_map[$label] = $reference;
@ -1026,7 +1028,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');

View File

@ -2,4 +2,5 @@
<p><code>this is also a codespan</code> trailing text</p>
<p><code>and look at this one!</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><code>sth `` sth</code></p>

View File

@ -6,4 +6,6 @@ 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` ``
`sth `` sth`

View File

@ -0,0 +1 @@
<p><a href="http://example.com" title="Title">single quotes</a> and <a href="http://example.com" title="Title">double quotes</a></p>

View File

@ -0,0 +1 @@
[single quotes](http://example.com 'Title') and [double quotes](http://example.com "Title")

View File

@ -1 +1,2 @@
<p><a href="http://example.com" title="Title">single quotes</a> and <a href="http://example.com" title="Title">double quotes</a></p>
<p><a href="http://example.com" title="example title">double quotes</a> and <a href="http://example.com" title="example title">single quotes</a> and <a href="http://example.com" title="example title">parentheses</a></p>
<p>[invalid title]: <a href="http://example.com">http://example.com</a> example title</p>

View File

@ -1 +1,6 @@
[single quotes](http://example.com 'Title') and [double quotes](http://example.com "Title")
[double quotes] and [single quotes] and [parentheses]
[double quotes]: http://example.com "example title"
[single quotes]: http://example.com 'example title'
[parentheses]: http://example.com (example title)
[invalid title]: http://example.com example title