2/18/2023 0 Comments Ka textmatePerhaps you'd be willing to try doing so yourself? This should be a very small tweak to any existing LaTeX syntax highlighter (just updating one list of commands to another). (I would venture to guess that it doesn't even know how many arguments they take, only their names.) I could see some value to adding a set of "red commands" that matches exactly what's in KaTeX's support table (but commands not on that list should definitely also be allowed). The special casing of \documentclass and \usepackage is just special casing it's not like the syntax highlighter knows what those commands mean, only that they're worth coloring red. Thanks for giving the specific example of what you don't like, though that's more helpful. (In fact, I would expect that most LaTeX syntax highlighters follow a process much closer to KaTeX's, whereas in LaTeX you can't really even lex correctly without running the code itself, as every token can be redefined at runtime.) That lexing process is pretty similar between LaTeX and KaTeX. I believe the general view by syntax highlighters is that they should not do this, but should just be running the lexing process and highlighting the different types of tokens. Because LaTeX and KaTeX allow defining commands at run time, it is provably impossible to know which commands are defined when parsing, except by running the code itself. \documentclass is lexically correct, but not valid in LaTeX or KaTeX (both will throw an "Undefined command/control sequence" error). I should probably take a closer look at that, according to the gifs here there might already be a nice LaTeX grammar (which may be good enough for highlighting KaTeX too although there might be some differences), maybe I just need to tweak my theme a little ? I'll post an update once I'll figure this out ? I'm embedding KaTeX in Markdown but I already have a grammar for Markdown. Probably would apply well to MathJax too?ĭid you want a grammar for Markdown LaTeX math, or some other combination? A grammar for LaTeX alone is probably not what you want. I want to syntax highlight KaTeX only yes. Maybe because you want to capture math only? Now that I think about it I may need to update the TextMate theme though, that output with the dark theme doesn't look right at all. ![]() I don't believe KaTeX implements all of LaTeX yet, right? ? Otherwise I could just use a LaTeX grammar for highlighting KaTeX, but I'm not sure there is a good one, I'm getting the following with the one GitHub is using (I believe): I'm embedding KaTeX specifically in my app, so that's what I want to syntax highlight. I'm a little confused why this is KaTeX-specific, and not LaTeX-general. So there might be a grammar there already that you could port to your editor of choice. Note that VSCode (since June 2021) supports Markdown LaTeX syntax, in particular letting you hover over math and it shows a KaTeX rendering. I found some StackOverflow questions and answers. Probably worth checking that MathJax and/or GitLab haven't done anything. For example, GitLab supports exactly that combination, though I believe with a weird math delimiter. ![]() Maybe Markdown is all that's important, though I certainly agree that that would be useful. I'm certainly all for syntax-highlighting grammars, though I worry about the complexity of X LaTeX math for too many values of X. Did you want a grammar for Markdown LaTeX math, or some other combination? A grammar for LaTeX alone is probably not what you want.Could you clarify? Maybe because you want to capture math only? Probably would apply well to MathJax too? I'm a little confused why this is KaTeX-specific, and not LaTeX-general.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |