diff --git a/services/web/frontend/js/features/source-editor/languages/typst/index.ts b/services/web/frontend/js/features/source-editor/languages/typst/index.ts index 7824d929a8..4d47492557 100644 --- a/services/web/frontend/js/features/source-editor/languages/typst/index.ts +++ b/services/web/frontend/js/features/source-editor/languages/typst/index.ts @@ -77,6 +77,9 @@ export const TypstLanguage = LRLanguage.define({ 'Strong/"*" Strong/StrongBody': t.strong, 'Emphasis/"_" Emphasis/EmphBody': t.emphasis, + // Bare URLs (https://... / http://...) + URL: t.url, + // Labels () and references (@name) 'Label/"<" Label/">" Label/LabelName': t.labelName, 'Ref/"@" Ref/RefName': t.labelName, diff --git a/services/web/frontend/js/features/source-editor/lezer-typst/tokens.mjs b/services/web/frontend/js/features/source-editor/lezer-typst/tokens.mjs index 61f0ee11c5..922f6827cc 100644 --- a/services/web/frontend/js/features/source-editor/lezer-typst/tokens.mjs +++ b/services/web/frontend/js/features/source-editor/lezer-typst/tokens.mjs @@ -35,6 +35,8 @@ const DOT = 46 // . const OPEN_PAREN = 40 // ( const COMMA = 44 // , const COLON = 58 // : +const OPEN_ANGLE = 60 // < +const CLOSE_ANGLE = 62 // > const KEYWORDS = new Set([ 'let', 'set', 'show', 'import', 'include', @@ -87,6 +89,17 @@ export const headingTitleTokenizer = new ExternalTokenizer( while (input.next !== -1 && input.next !== NEWLINE) { if (input.next === SLASH && (input.peek(1) === SLASH || input.peek(1) === STAR)) break + // Stop before a trailing '