commit 7b35b4d5e96aa15d95268262c3a4d3c803b6280b
parent 83a38a6e10d4ee48c4f07d71e218daed0dba8c9b
Author: Hunter
Date:   Wed, 24 Dec 2025 23:14:13 -0500

auto-match <style> and <script> tags

Diffstat:
Mmain.js | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/main.js b/main.js @@ -393,6 +393,20 @@ function initializeCodeMirror() { ...defaultKeymap ]), html(), + // Auto-close <style> and <script> tags (not handled by default html() extension) + EditorView.inputHandler.of((view, from, to, text) => { + if (text !== '>') return false; + const before = view.state.doc.sliceString(Math.max(0, from - 20), from); + const match = before.match(/<(style|script)(\s[^>]*)?$/i); + if (!match) return false; + const tagName = match[1].toLowerCase(); + const closingTag = `</${tagName}>`; + view.dispatch({ + changes: { from, to, insert: '>' + closingTag }, + selection: { anchor: from + 1 } + }); + return true; + }), githubDark, indentUnit.of("\t"), placeholder("Build something with HTML..."),