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);