0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

nixos/manual: convert <kbd> elements to bracketed spans

since support for kbd elements was added with explicit intent in #175128
it seems like a good idea to support this in nixos-render-docs instead
of just dropping it in favor of `*F12*` etc. since it's a very rare
thing in the manual and purely presentational it makes sense to use
bracketed spans instead of a new myst role.

the html-elements.lua plugin is now somewhat misnamed, but it'll go away
very soon so we don't want to bother renaming it.
This commit is contained in:
pennae 2023-02-08 06:30:27 +01:00
parent 65d749c80b
commit 1c9f55ec64
2 changed files with 10 additions and 10 deletions

View file

@ -2,10 +2,10 @@
Converts some HTML elements commonly used in Markdown to corresponding DocBook elements.
]]
function RawInline(elem)
if elem.format == 'html' and elem.text == '<kbd>' then
return pandoc.RawInline('docbook', '<keycap>')
elseif elem.format == 'html' and elem.text == '</kbd>' then
return pandoc.RawInline('docbook', '</keycap>')
function Span(elem)
if #elem.classes == 1 and elem.classes[1] == 'keycap' then
elem.content:insert(1, pandoc.RawInline('docbook', '<keycap>'))
elem.content:insert(pandoc.RawInline('docbook', '</keycap>'))
return elem
end
end