Skip to content

build book indexes from HTML markup

License

Notifications You must be signed in to change notification settings

unredacted-word/index-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

index builder

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 ;

examples

  • <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.

usage

  1. add index.js to your page
  2. add .ix-entry-cr .ix-entry-pages { display: none; } style to page
  3. markup your document
  4. add a placeholder <div id="index-entries"></div> where you want the index injected
  5. invoke buildIndex() when the page is done loading. profit 💥

the script will collect all .ix tags and build the index

About

build book indexes from HTML markup

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published