From 9d1ee99ee2fc0f7f52fd24f403c6b06ea5733d33 Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Sun, 30 Dec 2018 22:18:21 +0000 Subject: [PATCH] Add missing formatting tags to regex --- docx2md.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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);