Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ public function minifyHtml($html) {

private function _processSpaces() {
$this->_openXml = preg_replace("/( )/mi", " ", $this->_openXml);
$this->_openXml = preg_replace_callback(
'/<w:t.*?>(.*?)<\/w:t>/s',
function ($matches) {
$text = $matches[1];
/* Only remove leading and trailing spaces if they are not intentional. */
$text = preg_replace('/^\s+/', '', $text); // führende entfernen
return "<w:t>{$text}</w:t>";
},
$this->_openXml
);
$this->_openXml = preg_replace("/(<w:t>)/mi", "<w:t xml:space='preserve'>", $this->_openXml);

$this->_openXml = $this->minifyHtml($this->_openXml);
Expand Down Expand Up @@ -295,4 +305,4 @@ private function _getStyle($type, $wrap = true) {
return sprintf('<w:%1$sPr>%2$s</w:%1$sPr>', $type, $this->{$field});
}

}
}