asciidoctor.js
asciidoctor.js copied to clipboard
Get index terms line numbers from an Asciidoctor Extension
I'm working on a Node.js extension to make index terms searchable from the HTML output (via an input[type="search"]
and a <datalist>
elements).
I am looking to add one or many identifiers (via a role) to a section/block that contains index terms.
However, I did not find a way to match index terms from an extension. I managed to do it from within a custom converter, because we have access to Node elements there.
Is there a sensible way to parse index terms with doc.findBy()
? Or does it mean I have to extend the Html5Converter?
Can I use the default Html5Converter and provide mine, solely for the purpose of building a more precise catalog of indexed terms?
Your current approach is the correct one. This will remain true until we address https://github.com/asciidoctor/asciidoctor/issues/61.
One other option you have is to find blocks which are prose-like, then do your own index term processing. This is similar to the approach taken by asciidoctor-mathematical. See https://github.com/asciidoctor/asciidoctor-mathematical/blob/master/lib/asciidoctor-mathematical/extension.rb#L37-L43
Thanks, I forgot about this question being asked in #541 too.
It gives me enough elements to carry on this bit of work :)
Should we close this issue? @oncletom Is that OK?