Skip to content
This repository was archived by the owner on Aug 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from aneasystone/master
Browse files Browse the repository at this point in the history
Support for strikethrough, same as GFM
  • Loading branch information
egil committed Jun 29, 2015
2 parents 4b9aa21 + eed1ddf commit 916b2f0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion markdown_extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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.