asciidoctor.js icon indicating copy to clipboard operation
asciidoctor.js copied to clipboard

Get index terms line numbers from an Asciidoctor Extension

Open thom4parisot opened this issue 5 years ago • 3 comments

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?

thom4parisot avatar Feb 28 '19 10:02 thom4parisot

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

mojavelinux avatar Feb 28 '19 11:02 mojavelinux

Thanks, I forgot about this question being asked in #541 too.

It gives me enough elements to carry on this bit of work :)

thom4parisot avatar Feb 28 '19 11:02 thom4parisot

Should we close this issue? @oncletom Is that OK?

ggrossetie avatar Nov 01 '19 17:11 ggrossetie