diff --git a/app/Parsers/InlineHtmlParser.php b/app/Parsers/InlineHtmlParser.php
index 8ce758d..6ecf6a4 100644
--- a/app/Parsers/InlineHtmlParser.php
+++ b/app/Parsers/InlineHtmlParser.php
@@ -34,6 +34,17 @@ class InlineHtmlParser extends AbstractParser
protected array $items = [];
+ /**
+ * Stillat\BladeParser\Document\Document::fromText treats multibyte characters
+ * as indentations and spaces resulting in a miscalculated Node position.
+ *
+ * This function replaces the multibyte characters with a single, placeholder character
+ */
+ private function replaceMultibyteChars(string $text, string $placeholder = '*'): string
+ {
+ return preg_replace('/[^\x00-\x7F]/u', $placeholder, $text);
+ }
+
public function parse(InlineHtml $node)
{
if ($node->getStartPosition() > 0) {
@@ -46,7 +57,9 @@ public function parse(InlineHtml $node)
$this->startLine = $range->start->line;
}
- $this->parseBladeContent(Document::fromText($node->getText()));
+ $this->parseBladeContent(Document::fromText(
+ $this->replaceMultibyteChars($node->getText())
+ ));
if (count($this->items)) {
$blade = new Blade;
@@ -95,7 +108,7 @@ protected function doEchoParse(BaseNode $node, $prefix, $content)
}
$range->start->line += $this->startLine + $node->position->startLine - 2;
- $range->end->line += $this->startLine + $node->position->startLine - 2;
+ $range->end->line += $this->startLine + $node->position->startLine - 2;
return $range;
};