Skip to content

Automatically generates your index or table of contents for PrinceXML

Notifications You must be signed in to change notification settings

maraujop/princexml-indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

PrinceXML indexer

Automatically generates your index or table of contents for PrinceXML. This is a Bash script designed for injecting index references into a PrinceXML file and prompt the correspondent index lines. You can then copy paste those lines into your index file and regenerate your pdf.

What for?

I wrote my thesis using XML files. I generated the final pdf using PrinceXML and a CSS file based on Håkon Wium Lie's thesis CSS files. I split my work into several files, one for each chapter. I included all them in an index file using xi:include doing:

<xi:part>
    <xi:include href="introduction.xml"/>
    <xi:include href="technology.xml"/>
    <xi:include href="prototype.xml"/>
    [...]
</xi:part>

When I wrote the chapters, I didn't tag manually any of the headers, as I had in mind doing a script that did the dirty work for me. That's how PrinceXML indexer was born, as a fast hack done in a couple hours, so be gentle. My only regret, was not doing this script in Python.

Usage

First, It's recommendable to make a backup of the file. Then give indexer executable rights:

chmod +x indexer.sh

After doing so, you can run indexer doing:

./indexer.sh prince_file.xml

Indexer will find all headers (<h[1-6]>) and tag them using $filename-h$counter. So your first header will be id tagged id="prince_file-h1", the second one id="prince_file-h2" and so forth. Finally the script prompts the index lines that you can copy/paste in your index file:

$ ./indexer.sh prototype.xml 
<li class="chapter"><a href="#prototype-h1">Prototype</a><ul>
<li><a href="#prototype-h2">Design</a></li>
<li><a href="#prototype-h3">Landing page</a></li>
<li><a href="#prototype-h4">Authentication and user registration</a></li>
<li><a href="#prototype-h5">Social login</a></li>
<li><a href="#prototype-h6">Guided tour</a></li>
<li><a href="#prototype-h7">Start</a></li>
<li><a href="#prototype-h8">Publish a trip</a></li>
<li><a href="#prototype-h9">Tripboard</a></li>
<li><a href="#prototype-h10">Search system</a></li>
<li><a href="#prototype-h11">Warnings</a></li>
<li><a href="#prototype-h12">User profile</a><ul>
<li><a href="#prototype-h13">User profile edition</a></li>
<li><a href="#prototype-h14">Feedback</a></li>
<li><a href="#prototype-h15">Account configuration</a></li>
<li><a href="#prototype-h16">Inviting new users</a></li>
</ul></li>
<li><a href="#prototipo2-h17">Feedback</a></li>
</ul></li>

If you are using Håkon's CSS files, your index should then be something like this:

<div class="toc" id="toc">
    <ul class="toc">
        <!-- This is where you should put the index lines generated by indexer -->    
            
    </ul>
</div>
  • Don't run indexer on the file that contains the index or table of contents, you need to put that aside.
  • You can run indexer on an already tagged file, for example if you edit the xml files and you need to regenerate the index.
  • You can run indexer in a file that already has some ids in headers, but beware, that those ids will be overriden by indexer.
  • You can run indexer in the same file several times without side effects.

About

Automatically generates your index or table of contents for PrinceXML

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages