diff --git a/docx2md.php b/docx2md.php index ffb520d..66ce743 100755 --- a/docx2md.php +++ b/docx2md.php @@ -356,8 +356,10 @@ private function docx2md(array $args, $isTestMode = false) // Remove whitespace between tags $xml = preg_replace('/(\>)\s+(\<)/m', '\\1\\2', $xml); - // Ensure spacing exists between closing and opening tags - $xml = preg_replace('/(<\/i:(bold|italic)>)()([^\.,;:\?\!])/', '\\1 \\3\\5', $xml); + // Ensure spacing exists between closing and opening formatting tags + // unless punctuation is encountered + $anyFormattingTag = 'i:(bold|italic|strikethrough|line)'; + $xml = preg_replace("/(<\/{$anyFormattingTag}>)(<{$anyFormattingTag}>)([^\.,;:\?\!])/", '\\1 \\3\\5', $xml); $intermediaryDocument->loadXML($xml);