Skip to content

Commit

Permalink
implement GFM strikethrough
Browse files Browse the repository at this point in the history
  • Loading branch information
erusev committed Nov 21, 2013
1 parent b6f7959 commit 5a56300
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ private function parse_span_elements($text)

# ~

if (strpos($text, '~~') !== FALSE)
{
$text = preg_replace('/~~(?=\S)(.+?)(?<=\S)~~/s', '<del>$1</del>', $text);
}

if (strpos($text, '_') !== FALSE)
{
$text = preg_replace('/__(?=\S)(.+?)(?<=\S)__(?!_)/s', '<strong>$1</strong>', $text);
Expand Down
3 changes: 3 additions & 0 deletions tests/data/strikethrough.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p><del>strikethrough</del></p>
<p>in the <del>middle</del> of a sentence</p>
<p>in the middle of a w<del>or</del>d</p>
5 changes: 5 additions & 0 deletions tests/data/strikethrough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
~~strikethrough~~

in the ~~middle~~ of a sentence

in the middle of a w~~or~~d

0 comments on commit 5a56300

Please sign in to comment.