From 11d852fe18d02ac530f1b11fa61bb00aa2f77676 Mon Sep 17 00:00:00 2001 From: claude Date: Mon, 8 Jun 2026 19:29:46 +0000 Subject: [PATCH] Revert "chore: add browser diagnostic script for Typst highlighting" This reverts commit 8c9088d05415c613bd9064251c33e1b66acd6113. --- diagnostic-typst.js | 53 --------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 diagnostic-typst.js diff --git a/diagnostic-typst.js b/diagnostic-typst.js deleted file mode 100644 index 73f5a83af6..0000000000 --- a/diagnostic-typst.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Typst syntax highlighting diagnostics. - * Paste this entire file into the browser dev tools console - * while a Typst file is open in the editor. - */ - -// 1. Find the active CodeMirror editor view -const view = [...document.querySelectorAll('.cm-editor')] - .map(el => el.cmView?.view) - .find(Boolean) - -if (!view) { - console.error('No CodeMirror view found — make sure a file is open in the editor') -} else { - // 2. Show the language currently active - const lang = view.state.facet( - window.CM?.language?.language ?? view.state.facet.constructor - ) - console.log('Language:', view.state.languageDataAt('commentTokens', 0)) - - // 3. Print the top of the parse tree (first 800 chars) - const tree = view.state.tree - console.log('Parse tree (top):\n' + tree.toString().slice(0, 800)) - - // 4. Walk the first 20 leaf nodes and show their type + text - console.log('\nFirst 20 leaf nodes:') - let count = 0 - tree.iterate({ - enter(node) { - if (node.firstChild) return // skip non-leaf - if (count++ >= 20) return false - const text = view.state.doc.sliceString(node.from, node.to) - console.log(` [${node.name}] ${JSON.stringify(text.slice(0, 40))}`) - } - }) - - // 5. Check whether the Typst heading tokens exist at line 15-ish - const doc = view.state.doc - for (let ln = 1; ln <= Math.min(doc.lines, 20); ln++) { - const line = doc.line(ln) - if (line.text.trimStart().startsWith('=')) { - console.log(`\nLine ${ln} starts with '=': "${line.text}"`) - tree.iterate({ - from: line.from, - to: line.to, - enter(node) { - const t = doc.sliceString(node.from, node.to) - console.log(` node: ${node.name} text: ${JSON.stringify(t.slice(0, 60))}`) - } - }) - } - } -}