Syntax highlighting on the web | Joel Gustafson
In IDEs, syntax highlighting has traditionally been implemented in a mode-based pattern matching approach. Each language "grammar" defines a set of scopes, regular expressions that match different kinds of tokens in each scope, and inclusions of scopes inside other scopes. The capturing groups in the regular expressions are then associated with names in some taxonomy that themes interface with. I put "grammar" in quotes because they're very different from actual formal grammars (ABNF etc). Code editing as we know it is really a stack of several mostly-independent features, each of which has different priorities and ends up involving a different version of "parsing". IDEs mostly want syntax highlighting to be fast and forgiving. We expect our tokens to be colored "correctly" even in invalid/intermediate states, and we expect highlighting to happen basically instantly. This means that lots of systems converged on loose regex-based approaches that could identify keywords and operators and
--> Syntax highlighting on the web | Joel Gustafson Syntax highlighting on the web Joel Gustafson / Posts / 2022-05-31 How does syntax highlighting work? In IDEs, syntax highlighting has traditionally been implemented in a mode-based pattern matching approach. Each language "grammar" defines a set of scopes, regular expressions that match different kinds of tokens in each scope, and inclusions of scopes inside other scopes. The capturing groups in the regular expressions are then associated with names in some taxonomy that themes interface with. I put "grammar" in quotes because they're very d
Explore this link on the map →related reading
- I am sorry, but everyone is getting syntax highlighting wrong @ tonsky.metonsky.me
- Tristan's Site - Tristan Humethume.ca
- Monaspacemonaspace.githubnext.com
- Reading 12: Regular Expressions & Grammarsweb.mit.edu
- Web Highlighter: a mini tool for highlighting website textalienzhou.github.io
- Laurence Tratt: Which Parsing Approach?tratt.net
- Idea Listjzhao.xyz
- The Evolution of Shiki v1.0 · Nuxt Blognuxt.com
- Fast regex search: indexing text for agent tools · Cursorcursor.com
- GitHub - dexterouslogic/super-simple-highlighter: A chrome extension which highlights text on a web page, and attempts to restore it on returning · GitHubgithub.com
- Representing Code · Crafting Interpreterscraftinginterpreters.com
- Hemingway Editorhemingwayapp.com