mark up your document with index annotations, by adding a classname to any tag it'll be marked to indexing. By default index-builder will use the the textContent of the tag, but you can customize the text with a data-attribute if the index entry doesn't match the inline text.
- classname:
.ix - attribute:
data-ix
This is a block of text with <span class="ix">annotations</span>.
By default, the <span class="ix" data-ix"html DOM">textContent</span> in the tag
is used as the index entry. If you need to change the index entry, you can add
the data-ix attribute and specify different text. You can also use this
attribute to specify multiple entries, separated by ;<span class="ix">Chipotle</span>adds "Chipotle" to index.<span class="ix" data-ix"McDonald, Ronald">Ronald McDonald</span>adds "McDonald, Ronald" to index. Note, since it is a proper name, it doesn't add a subentry.<span class="ix" data-ix"foods;snacks, fast food">junk food</span>adds two entries to the index: "foods", and "snacks" with "fast food" as a subentry of "snacks".<span class="ix" data-ix="time, pseudo-cyclical see also pseudo-cyclical time">time</span>Adds an entry for "time, pseudo-cyclical" with a cross reference to "pseduo-cyclical time". The cross reference page number will display the page number, instead it'll be listed in the referenced entry.
- add
index.jsto your page - add
.ix-entry-cr .ix-entry-pages { display: none; }style to page - markup your document
- add a placeholder
<div id="index-entries"></div>where you want the index injected - invoke
buildIndex()when the page is done loading. profit 💥
the script will collect all .ix tags and build the index