Closed maurosilber closed 3 months ago
Hello, I didn't know about the abbr
tag, thanks!
However, acronyms is meant to be format-agnostic by working directly with Markdown (both input and output). I fear that trying to change the behaviour specifically when the output is HTML would make the project too complex, error-prone and more difficult to test.
One thing you could do without changing the core behaviour of acronyms is to create a new style. The style determines how acronyms are rendered in the text. You can create a new style that outputs something like "<abbr>" .. acronym.shortname .. "</abbr> (" .. acronym.longname .. ")"
(which would translate to "<abbr>CSS</abbr> (Cascading Style Sheets)"
).
Great, this works for me, thank you!
If anybody is interested, I added the following style to _extensions/rchaput/acronyms/acronyms_styles.lua
:
styles["html-abbr"] = function(acronym, insert_links, is_first_use)
if quarto.doc.isFormat('html') then
local text = '<abbr title="' .. acronym.longname .. '">' .. acronym.shortname .. '</abbr>'
if is_first_use then
text = acronym.longname .. " (" .. text .. ")"
end
return pandoc.RawInline('html', text)
end
return styles["long-short"](acronym, insert_links, is_first_use)
end
which shows a tooltip when hovering on the <abbr>
:
Hi!
Would it be possible to support using
<abbr>
when outputting HTML? I think it provides a better UX than links to the list of acronyms.I woudn't mind creating a pull request if it is simple to implement.
Thanks for this extension!