Closed andrewpbray closed 5 months ago
Mmmm, good question! One potential reason to go for JS is that we know we won't mess with any of Quarto's treatment of the code block — if it's Lua and there's code block processing happening after, that could break.
Ah, good point!
That said, Quarto does offer a lot of control over Lua filter execution timing now!
I chatted with Christoph at the Quarto office hours about this. Learned a lot and came down on the side of JS.
@jimjam-slam While thinking through how to build the code-highlighting feature, I took a look at the HTML produced by revealjs.
The separate of each line of code into (labeled) spans makes it pretty easy to assign the
highlight-line
class to particular lines and thenhas-highlights
to the wrappingcode
tag. It got me wondering: should this be implemented in Lua or JS? 🤔The Lua approach would seem to be:
cr-id
(say:penguins-plot-hl-1
).The JS approach would just be to modify the existing DOM, adding and removing those classes when necessary.
The only advantage that I can see to the Lua approach is that if we wanted, we could later extend it to do something helpful if the author wanted a non-interactive version of the page (either static html or pdf). The advantage of the JS approach is that it keeps the DOM a bit leaner (we're not duplicating blocks) and it makes it possible to think of closeread more like closereadjs - a JS library that could be used independently of Quarto.
Thoughts?