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

Compare commits

...

7 Commits
1.4.1 ... 1.4.5

Author SHA1 Message Date
ada39109e4 resolve #189 2015-01-15 22:04:02 +02:00
a06cdfb814 improve fix for #184 2015-01-15 21:32:18 +02:00
6bee326c92 resolve #184 2015-01-15 21:10:09 +02:00
3fe867d294 update readme 2015-01-15 18:28:11 +02:00
f08d017bcb resolve #196 2015-01-15 02:45:45 +02:00
e61a6114b0 resolve #175 2015-01-15 02:37:20 +02:00
9ed72ccd09 resolve #126 2015-01-15 02:24:39 +02:00
8 changed files with 37 additions and 15 deletions

View File

@ -32,8 +32,7 @@ class Parsedown
$this->DefinitionData = array(); $this->DefinitionData = array();
# standardize line breaks # standardize line breaks
$text = str_replace("\r\n", "\n", $text); $text = str_replace(array("\r\n", "\r"), "\n", $text);
$text = str_replace("\r", "\n", $text);
# remove surrounding line breaks # remove surrounding line breaks
$text = trim($text, "\n"); $text = trim($text, "\n");
@ -559,6 +558,11 @@ class Parsedown
return $Block; return $Block;
} }
if ($Line['text'][0] === '[' and $this->blockReference($Line))
{
return $Block;
}
if ( ! isset($Block['interrupted'])) if ( ! isset($Block['interrupted']))
{ {
$text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
@ -892,6 +896,11 @@ class Parsedown
protected function blockTableContinue($Line, array $Block) protected function blockTableContinue($Line, array $Block)
{ {
if (isset($Block['interrupted']))
{
return;
}
if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
{ {
$Elements = array(); $Elements = array();
@ -901,9 +910,9 @@ class Parsedown
$row = trim($row); $row = trim($row);
$row = trim($row, '|'); $row = trim($row, '|');
$cells = explode('|', $row); preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
foreach ($cells as $index => $cell) foreach ($matches[0] as $index => $cell)
{ {
$cell = trim($cell); $cell = trim($cell);
@ -1298,7 +1307,7 @@ class Parsedown
return; return;
} }
if (preg_match('/^\([ ]*([^ ]+?)(?:[ ]+(".+?"|\'.+?\'))?[ ]*\)/', $remainder, $matches)) if (preg_match('/^[(]((?:[^ (]|[(][^ )]+[)])+)(?:[ ]+("[^"]+"|\'[^\']+\'))?[)]/', $remainder, $matches))
{ {
$Element['attributes']['href'] = $matches[1]; $Element['attributes']['href'] = $matches[1];
@ -1507,7 +1516,7 @@ class Parsedown
# Read-only # Read-only
protected $specialCharacters = array( protected $specialCharacters = array(
'\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|',
); );
protected $StrongRegex = array( protected $StrongRegex = array(

View File

@ -10,9 +10,8 @@ Better Markdown Parser in PHP
* [Consistent](http://parsedown.org/consistency) * [Consistent](http://parsedown.org/consistency)
* [GitHub flavored](https://help.github.com/articles/github-flavored-markdown) * [GitHub flavored](https://help.github.com/articles/github-flavored-markdown)
* [Tested](http://parsedown.org/tests/) in PHP 5.2, 5.3, 5.4, 5.5, 5.6 and [hhvm](http://www.hhvm.com/) * [Tested](http://parsedown.org/tests/) in PHP 5.2, 5.3, 5.4, 5.5, 5.6 and [hhvm](http://www.hhvm.com/)
* Extensible * [Extensible](https://github.com/erusev/parsedown/wiki/Writing-Extensions)
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra) * [Markdown Extra extension](https://github.com/erusev/parsedown-extra)
* [JavaScript port](https://github.com/hkdobrev/parsedown.js) under development
### Installation ### Installation

View File

@ -1,4 +1,4 @@
<p><a href="http://example.com">link</a> and <a href="/tests/">another link</a></p> <p><a href="http://example.com">link</a> and <a href="/url-with-(parentheses)">another link</a></p>
<p><a href="http://example.com"><code>link</code></a></p> <p><a href="http://example.com"><code>link</code></a></p>
<p><a href="http://example.com"><img src="http://parsedown.org/md.png" alt="MD Logo" /></a></p> <p><a href="http://example.com"><img src="http://parsedown.org/md.png" alt="MD Logo" /></a></p>
<p><a href="http://example.com"><img src="http://parsedown.org/md.png" alt="MD Logo" /> and text</a></p> <p><a href="http://example.com"><img src="http://parsedown.org/md.png" alt="MD Logo" /> and text</a></p>

View File

@ -1,4 +1,4 @@
[link](http://example.com) and [another link](/tests/) [link](http://example.com) and [another link](/url-with-(parentheses))
[`link`](http://example.com) [`link`](http://example.com)

View File

@ -1 +1,4 @@
<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="Title">single quotes</a></p>
<p><a href="http://example.com" title="Title">double quotes</a></p>
<p><a href="http://example.com" title="2 Words">space</a></p>
<p><a href="http://example.com/url-(parentheses)" title="Title">parentheses</a></p>

View File

@ -1 +1,7 @@
[single quotes](http://example.com 'Title') and [double quotes](http://example.com "Title") [single quotes](http://example.com 'Title')
[double quotes](http://example.com "Title")
[space](http://example.com "2 Words")
[parentheses](http://example.com/url-(parentheses) "Title")

View File

@ -11,8 +11,12 @@
<td><del>cell</del> 1.2</td> <td><del>cell</del> 1.2</td>
</tr> </tr>
<tr> <tr>
<td><code>cell</code> 2.1</td> <td><code>|</code> 2.1</td>
<td>cell 2.2</td> <td>| 2.2</td>
</tr>
<tr>
<td><code>\|</code> 2.1</td>
<td><a href="/">link</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -1,4 +1,5 @@
| _header_ 1 | header 2 | | _header_ 1 | header 2 |
| ------------ | ------------ | | ------------ | ------------ |
| _cell_ 1.1 | ~~cell~~ 1.2 | | _cell_ 1.1 | ~~cell~~ 1.2 |
| `cell` 2.1 | cell 2.2 | | `|` 2.1 | \| 2.2 |
| `\|` 2.1 | [link](/) |