Fix syntax highlighting of Lua expressions that start with whitespace
parent
8e8acbb470
commit
5b982ac257
|
@ -357,6 +357,9 @@ const LuaDirectives: MarkdownConfig = {
|
||||||
// Let's parse as an expression
|
// Let's parse as an expression
|
||||||
const parsedExpression = luaLanguage.parser.parse(`_(${bodyText})`);
|
const parsedExpression = luaLanguage.parser.parse(`_(${bodyText})`);
|
||||||
|
|
||||||
|
// If bodyText starts with whitespace, we need to offset this later
|
||||||
|
const whiteSpaceOffset = bodyText.match(/^\s*/)?.[0].length ?? 0;
|
||||||
|
|
||||||
const node = parsedExpression.resolveInner(2, 0).firstChild?.nextSibling
|
const node = parsedExpression.resolveInner(2, 0).firstChild?.nextSibling
|
||||||
?.nextSibling;
|
?.nextSibling;
|
||||||
|
|
||||||
|
@ -367,7 +370,7 @@ const LuaDirectives: MarkdownConfig = {
|
||||||
"LuaExpressionDirective",
|
"LuaExpressionDirective",
|
||||||
pos + 2,
|
pos + 2,
|
||||||
endPos - 1,
|
endPos - 1,
|
||||||
[cx.elt(node.toTree()!, pos + 2)],
|
[cx.elt(node.toTree()!, pos + 2 + whiteSpaceOffset)],
|
||||||
);
|
);
|
||||||
|
|
||||||
return cx.addElement(
|
return cx.addElement(
|
||||||
|
|
Loading…
Reference in New Issue