oreillymedia / asciidoctor-htmlbook

Templates for the htmlbook backend for Asciidoctor
45 stars 15 forks source link

Index Handling improvements #66

Closed sandersk closed 9 years ago

sandersk commented 9 years ago

Hi @sarahs,

Hope you don't mind, but I went ahead and made some improvements to the AsciiDoctor backend for indexterms. Here's a summary:

These three attributes map to data-primary-sortas, data-secondary-sortas, and data-tertiary-sortas, respectively, in HTMLBook.

Additionally, I've preserved support for the legacy sortas attribute. The way it works now is that if none of the other three above attributes are supplied, sortas will be applied to the deepest-level term in the indexterm. So, for example, in:

((("1", "2", sortas="two")))

The sortas attribute is applied to the secondary entry of "2". The resulting HTMLBook is:

<a data-type="indexterm" data-primary="1" data-secondary="2" data-secondary-sortas="two"/>
First paragraph((("two paras", id="twoparas")))
Second paragraph(((startref="twoparas")))

That's all you need. I think this is much simpler from the indexer's perspective, as it's one less attribute to worry about.

Important note: putting primary/secondary/tertiary entries on the end-of-range indexterm is optional, but if you do, they must exactly match those on the start-of-range indexterm. I recommend that indexers skip adding primary/secondary/tertiary entries on end-of-range indexterms, as again it's one less thing to worry about.

Could you review and merge/deploy if it looks good? Also, if there's any documentation that needs to be updated, could you help update that as well? Let me know if you have any questions/concerns.

Thanks, Sanders