From 5a563008aa2b63161363fc3abe0e1b3345f1299a Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Thu, 21 Nov 2013 13:39:00 +0200 Subject: [PATCH] implement GFM strikethrough --- Parsedown.php | 5 +++++ tests/data/strikethrough.html | 3 +++ tests/data/strikethrough.md | 5 +++++ 3 files changed, 13 insertions(+) create mode 100644 tests/data/strikethrough.html create mode 100644 tests/data/strikethrough.md diff --git a/Parsedown.php b/Parsedown.php index c84ae75..e4c2ad3 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -766,6 +766,11 @@ class Parsedown # ~ + if (strpos($text, '~~') !== FALSE) + { + $text = preg_replace('/~~(?=\S)(.+?)(?<=\S)~~/s', '$1', $text); + } + if (strpos($text, '_') !== FALSE) { $text = preg_replace('/__(?=\S)(.+?)(?<=\S)__(?!_)/s', '$1', $text); diff --git a/tests/data/strikethrough.html b/tests/data/strikethrough.html new file mode 100644 index 0000000..bdcdc41 --- /dev/null +++ b/tests/data/strikethrough.html @@ -0,0 +1,3 @@ +

strikethrough

+

in the middle of a sentence

+

in the middle of a word

\ No newline at end of file diff --git a/tests/data/strikethrough.md b/tests/data/strikethrough.md new file mode 100644 index 0000000..6c7efaf --- /dev/null +++ b/tests/data/strikethrough.md @@ -0,0 +1,5 @@ +~~strikethrough~~ + +in the ~~middle~~ of a sentence + +in the middle of a w~~or~~d \ No newline at end of file