From 7605177a6b5e3dc4132e0bb6453a2d00ada01925 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 18 Nov 2013 00:38:33 +0100 Subject: [PATCH] Added strike through support to Markdown --- src/CustomMarkdown.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CustomMarkdown.php b/src/CustomMarkdown.php index 06100def..2e4df205 100644 --- a/src/CustomMarkdown.php +++ b/src/CustomMarkdown.php @@ -5,7 +5,8 @@ class CustomMarkdown extends \Michelf\Markdown { $this->no_markup = true; $this->span_gamut += ['doSpoilers' => 71]; - $this->span_gamut += ['doUsers' => 7]; + $this->span_gamut += ['doSpoilers' => 71]; + $this->span_gamut += ['doStrike' => 6]; $this->span_gamut += ['doPosts' => 8]; $this->span_gamut += ['doTags' => 9]; $this->span_gamut += ['doAutoLinks2' => 29]; @@ -45,6 +46,14 @@ class CustomMarkdown extends \Michelf\Markdown return preg_replace_callback('/\n/', [&$this, '_doHardBreaks_callback'], $text); } + protected function doStrike($text) + { + return preg_replace_callback('{(~~|---)([^~]+)\1}', function($x) + { + return $this->hashPart('') . $x[2] . $this->hashPart(''); + }, $text); + } + protected function doSpoilers($text) { if (is_array($text))