From 210342a5bfff49c1f23df80cfb45544408bbdaa1 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 17 Nov 2013 14:20:59 +0100 Subject: [PATCH] Fixes to Markdown - aa_bb cc_dd doesn't produce italics anymore - asd@5.com doesn't produce link to post 5 - asd.com#anchor doesn't produce link to tag "anchor" --- src/CustomMarkdown.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/CustomMarkdown.php b/src/CustomMarkdown.php index 94f77102..c147bec7 100644 --- a/src/CustomMarkdown.php +++ b/src/CustomMarkdown.php @@ -8,6 +8,16 @@ class CustomMarkdown extends \Michelf\Markdown $this->span_gamut += ['doPosts' => 8]; $this->span_gamut += ['doTags' => 9]; $this->span_gamut += ['doAutoLinks2' => 29]; + + //fix italics/bold in the middle of sentence + $prop = ['em_relist', 'strong_relist', 'em_strong_relist']; + for ($i = 0; $i < 3; $i ++) + { + $this->{$prop[$i]}[''] = '(?:(?{$prop[$i]}[str_repeat('*', $i + 1)] = '(?<=\S|^)(?{$prop[$i]}[str_repeat('_', $i + 1)] = '(?<=\S|^)(?hashPart('') . $x[0] . $this->hashPart(''); }, $text); @@ -51,7 +61,7 @@ class CustomMarkdown extends \Michelf\Markdown protected function doTags($text) { - return preg_replace_callback('/#([a-zA-Z0-9_-]+)/', function($x) + return preg_replace_callback('/(?:(?hashPart('') . $x[0] . $this->hashPart(''); }, $text);