@bramus curious to know, would this work for text inside <textarea>?
7 comments
@bramus that's actually the exact thing that I want to implement (for some time). I also couldn't find any reasons except some comments confirming that inputs/textareas don't work 😢 @cheeaun @bramus I was thinking of hacking something for textarea based on https://github.com/kueblc/LDT (which overlays a transparent <textarea> on top of a styled <pre>) Not sure the highlight API has been thought out for dynamic content... I don't know if you can change the bounds of a range after it's been registered and have the output updated... We'll see 🙂 @pygy @cheeaun Perfectly possible. Here's a demo that does on-the-fly highlighting: https://www.bram.us/2024/02/18/custom-highlight-api-for-syntax-highlighting/#highlighting-contenteditable That makes LDT redundant... Prism is ~10Kb larger, but its parsing abilities is heaps and bounds better than what LDT offers with just regexps. Prism also supports styling the content of script and style tags in HTML, out of the box... |
@cheeaun Doesn't work on inputs/textareas (for some reason I haven't found yet)