Permalink
Browse files

Merge pull request #10 from aneasystone/master

Support for strikethrough, same as GFM
  • Loading branch information...
2 parents 4b9aa21 + eed1ddf commit 916b2f0bfe6d92bf5f6cf36dcfed2e5f73a9920a @egil committed Jun 29, 2015
Showing with 17 additions and 1 deletion.
  1. +17 −1 markdown_extended.php
View
@@ -18,7 +18,9 @@ function MarkdownExtraExtended_Parser($default_classes = array()) {
$this->block_gamut += array(
"doFencedFigures" => 7,
);
-
+ $this->span_gamut += array(
+ "doStrikethroughs" => -35
+ );
parent::MarkdownExtra_Parser();
}
@@ -157,5 +159,19 @@ function _doFencedFigures_callback($matches) {
$res .= "</figure>";
return "\n". $this->hashBlock($res)."\n\n";
}
+ function doStrikethroughs($text) {
+ #
+ # Replace ~~some deleted text~~ with <del>some deleted text</del>
+ #
+ $text = preg_replace_callback('{
+ ~~([^~]+)~~
+ }xm',
+ array(&$this, '_doStrikethroughs_callback'), $text);
+ return $text;
+ }
+ function _doStrikethroughs_callback($matches) {
+ $res = "<del>" . $matches[1] . "</del>";
+ return $this->hashBlock($res);
+ }
}
?>

0 comments on commit 916b2f0

Please sign in to comment.