Revert "chore: add browser diagnostic script for Typst highlighting"
Build and Deploy Verso / deploy (push) Successful in 1m15s
Build and Deploy Verso / deploy (push) Successful in 1m15s
This reverts commit 8c9088d054.
This commit is contained in:
@@ -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))}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user