asciidoctor / asciidoctor.js

:scroll: A JavaScript port of Asciidoctor, a modern implementation of AsciiDoc
https://asciidoctor.org
MIT License
719 stars 131 forks source link

Get index terms line numbers from an Asciidoctor Extension #684

Open thom4parisot opened 5 years ago

thom4parisot commented 5 years ago

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?

mojavelinux commented 5 years ago

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

thom4parisot commented 5 years ago

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

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

ggrossetie commented 4 years ago

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