We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 783e618 commit 6032e39Copy full SHA for 6032e39
src/Parser.php
@@ -102,7 +102,7 @@ public function parse()
102
$returnValue = $element->ownerDocument->saveXML($element);
103
104
if ($this->format === Format::PLAIN_TEXT) {
105
- $returnValue = strip_tags($returnValue);
+ $returnValue = Utils::stripTagsMaintainWhitespace($returnValue);
106
}
107
108
$returnValue = trim($returnValue);
src/Utils.php
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+namespace DivineOmega\WikitextParser;
4
5
+class Utils
6
+{
7
+ public static function stripTagsMaintainWhitespace(string $html)
8
+ {
9
+ $plaintext = $html;
10
+ $plaintext = str_replace('<', ' <', $plaintext);
11
+ $plaintext = strip_tags($plaintext);
12
+ $plaintext = str_replace(' ', ' ', $plaintext);
13
14
+ return $plaintext;
15
+ }
16
+}
0 commit comments