-
-
Notifications
You must be signed in to change notification settings - Fork 140
Description
Did you check existing issues?
- I have read all the tree-sitter docs if it relates to using the parser
- I have searched the existing issues of tree-sitter-typescript
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
No response
Describe the bug
Hello,
I originally created an issue at zed-latex about this syntax highlighting bug but have been directed to the TypeScript language, which I believe is here?
This is an example test with broken syntax-highlighting, where I create a LaTeX string, in TypeScript:
LaTeX makes heavy use of the backslash character, and I've found String.raw helps to ignore character escape sequences.
I noticed removing the line \usepackage{graphicx} fixes the issue. If I remove it the colours are now back to normal:
Steps To Reproduce/Bad Parse Tree
The code from the screenshot:
test('image', async () => {
const latex = String.raw`
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[]{image.png}
\end{document}
`;
const markdown = await testProcessor.latex(latex);
// console.log(markdown);
const expectedMarkdown = unindentStringAndTrim(`

`);
expect(markdown).toBe(expectedMarkdown);
const html = await testProcessor.md(markdown);
// console.log(html);
const expectedHtml = unindentStringAndTrim(`
<p><img src="image.png" alt="Image" /></p>
`);
expect(html).toBe(expectedHtml);
// const quartoHtml = await markdownToQuartoHtml(markdown);
// console.log(quartoHtml);
});(Just looking at GitHub's syntax highlighting here, it also seems to struggle with the line \usepackage{graphicx}. Perhaps \u is problematic as it can represent the unicode escape sequence).
Expected Behavior/Parse Tree
Syntax highlighting works correctly for TypeScript files which include strings of LaTeX code using String.raw.