Built-in Regex-Based Syntax Highlighting for Code Blocks #61
Closed
Samyssmile
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
notectl aims to provide IDE-like capabilities. The
CodeBlockPluginalready ships a complete code editing experience (keyboard handling, indentation, copy-to-clipboard, language attribute, input rules). It also defines a pluggableSyntaxHighlighterinterface with a built-in regex-based tokenizer. Users get syntax coloring out of the box for supported languages.This discussion captures research findings and tracks what has been delivered and what remains for full syntax highlighting support.
Current Status
CodeBlockPluginwith full editing supportSyntaxHighlighterinterfacenotectl-token--{type}classes)```java+ Space → code block with language)setLanguage(),getSupportedLanguages())RegexTokenizer.ts) — Java, JSON, XMLThemeSyntax, 16 token types, light + dark)What Was Implemented
Regex Tokenizer (
RegexTokenizer.ts)SyntaxHighlighterinterface with regex-based tokenizationplugins/code-block/highlighter/Syntax Token Colors in Theme System (
SyntaxTokenTypes.ts)ThemeSyntaxmapped type with 16 canonical token types:keyword,string,comment,number,function,operator,punctuation,boolean,null,property,type,annotation,tag,attribute,constant,regexcolor, optionalfontStyleandfontWeightLIGHT_THEMEandDARK_THEMEThe SyntaxHighlighter Interface
The
RegexTokenizerimplements this interface. The existing Decorations system handles the rest — mapping tokens to inline decorations with CSS classes.User Workflow
Power user: Markdown shortcut (works today)
Regular user: Toolbar / keyboard shortcut (UX gap)
Remaining Scope
Additional target languages
Python, Go, JavaScript, TypeScript
Language picker UI
Make the language label in the code block header clickable, show dropdown of supported languages.
Open Questions
Beta Was this translation helpful? Give feedback.
All reactions