File tree 1 file changed +15
-2
lines changed
Filter options
1 file changed +15
-2
lines changed
Original file line number Diff line number Diff line change @@ -34,6 +34,17 @@ class InlineHtmlParser extends AbstractParser
34
34
35
35
protected array $ items = [];
36
36
37
+ /**
38
+ * Stillat\BladeParser\Document\Document::fromText treats multibyte characters
39
+ * as indentations and spaces resulting in a miscalculated Node position.
40
+ *
41
+ * This function replaces the multibyte characters with a single, placeholder character
42
+ */
43
+ private function replaceMultibyteChars (string $ text , string $ placeholder = '* ' ): string
44
+ {
45
+ return preg_replace ('/[^\x00-\x7F]/u ' , $ placeholder , $ text );
46
+ }
47
+
37
48
public function parse (InlineHtml $ node )
38
49
{
39
50
if ($ node ->getStartPosition () > 0 ) {
@@ -46,7 +57,9 @@ public function parse(InlineHtml $node)
46
57
$ this ->startLine = $ range ->start ->line ;
47
58
}
48
59
49
- $ this ->parseBladeContent (Document::fromText ($ node ->getText ()));
60
+ $ this ->parseBladeContent (Document::fromText (
61
+ $ this ->replaceMultibyteChars ($ node ->getText ())
62
+ ));
50
63
51
64
if (count ($ this ->items )) {
52
65
$ blade = new Blade ;
@@ -95,7 +108,7 @@ protected function doEchoParse(BaseNode $node, $prefix, $content)
95
108
}
96
109
97
110
$ range ->start ->line += $ this ->startLine + $ node ->position ->startLine - 2 ;
98
- $ range ->end ->line += $ this ->startLine + $ node ->position ->startLine - 2 ;
111
+ $ range ->end ->line += $ this ->startLine + $ node ->position ->startLine - 2 ;
99
112
100
113
return $ range ;
101
114
};
You can’t perform that action at this time.
0 commit comments