Browse Source

Add strikethrough back

pull/440/head
danpros 4 years ago
parent
commit
03b740c442
2 changed files with 30 additions and 1 deletions
  1. +1
    -1
      system/admin/editor/js/Markdown.Editor.js
  2. +29
    -0
      system/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php

+ 1
- 1
system/admin/editor/js/Markdown.Editor.js View File

@ -1483,7 +1483,7 @@
buttons.bold = makeButton("wmd-bold-button", getString("bold"), "fa fa-bold", bindCommand("doBold"));
buttons.italic = makeButton("wmd-italic-button", getString("italic"), "fa fa-italic", bindCommand("doItalic"));
buttons.heading = makeButton("wmd-heading-button", getString("heading"), "fa fa-header", bindCommand("doHeading"));
//buttons.strikethrough = makeButton("wmd-strikethrough-button", getString("strikethrough"), "fa fa-strikethrough", bindCommand("doStrikethrough"));
buttons.strikethrough = makeButton("wmd-strikethrough-button", getString("strikethrough"), "fa fa-strikethrough", bindCommand("doStrikethrough"));
//makeSpacer(1);
buttons.olist = makeButton("wmd-olist-button", getString("olist"), "fa fa-list-ol", bindCommand(function (chunk, postProcessing) {
this.doList(chunk, postProcessing, true);


+ 29
- 0
system/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php View File

@ -139,6 +139,7 @@ class MarkdownExtra extends \Michelf\Markdown {
);
$this->span_gamut += array(
"doFootnotes" => 5,
"doStrikethrough" => 55,
"doAbbreviations" => 70,
);
@ -1890,4 +1891,32 @@ class MarkdownExtra extends \Michelf\Markdown {
}
return $matches[0];
}
protected function doStrikethrough($text) {
#
# Strikethrough:
# in: text ~~deleted~~ from doc
# out: text <del>deleted</del> from doc
#
$parts = preg_split('/(?<![~])(~~)(?![~])/', $text, null, PREG_SPLIT_DELIM_CAPTURE);
//don't bother if nothing to do...
if(count($parts) <= 1)
return $text;
$inTag = false;
foreach($parts as &$part) {
if($part == '~~') {
$part = ($inTag ? '</del>' : '<del>');
$inTag = !$inTag;
}
}
//no hanging delimiter
if($inTag)
$parts[] = '</del>';
return implode('', $parts);
}
}

Loading…
Cancel
Save