by mg · 11mo ago · 0 comments
The ease of use to highlight static text via Arborium seems nice:
<script src="arborium.iife.js"></script>
<pre><code class="language-python">
def hello(name):
print("Hello " + name);
</code></pre>
But does it support editing highlighted text? If not, one would have to do some trickery by hiding a textarea and updating the <code> element on each keypress, I guess. Which probably has a thousand corner cases one would have to deal with.And how would one add SCAD support?
The code isn't minified so you can see how they do it by looking at the `doHighlight()` function here https://arborium.bearcove.eu/pkg/app.generated.js
Hmm .. and the approach already shows its weaknesses when I play with it: When I search for something on the page, it gives me twice as many hits as there are. And jumps around two times to each hit when I use the "next" button.
I wonder if that is fixable.
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...
https://developer.mozilla.org/en-US/docs/Web/API/Highlight
All the trickery vanishes and you get first-class CSS support.
https://github.blog/engineering/architecture-optimization/cr...