How can I make an index? #10

Open
opened 5 years ago by ghost · 2 comments
ghost commented 5 years ago (Migrated from github.com)

Hi!

I have been reading the documentation at: https://docs.racket-lang.org/pollen/quick-tour.html , but I didn't find the topic about how to make an index (when creating a book).

There is an example in the last link in this page: https://robjhyndman.com/hyndsight/indexing-in-latex/

Thank you for any help.

Alexandre.

Hi! I have been reading the documentation at: https://docs.racket-lang.org/pollen/quick-tour.html , but I didn't find the topic about how to make an index (when creating a book). There is an example in the last link in this page: https://robjhyndman.com/hyndsight/indexing-in-latex/ Thank you for any help. Alexandre.
otherjoel commented 5 years ago (Migrated from github.com)

Pollen has no built-in facilities for building a keyword index for HTML; each author must design and implement their own system. It's quite an exercise. (Obviously, if you’re only targeting PDF via LaTeX, you can just use LaTeX’s system for this)

I have written a pretty good one for an upcoming project. Here’s an example of the output. It supports sub-entries using ! as a separator, with the idea that it will plug into LaTeX pretty easily if I need it to.

Roughly:

  • In HTML, my ◊index tag function calls html-index, which produces a link to the keyword index page with a custom attribute data-index-entry as a kind of marker so it can be found again in the next step.
  • My site uses a SQLite database to cache a bunch of stuff about each article each time it is rendered. (I decided to have a bit of fun and call this “crystalization”) As part of this process, the crystalize-index-entries! function is called, which finds all links with a data-index-entry attribute, and saves info about them into the keywordindex table of the database.
  • The program which generates the index is keyword-index.rkt.
  • Because each article also has its own row in the database, I can use the rowid column to simulate page numbers in the output.

A few years ago I prototyped another system which was much simpler. See these lines in pollen.rkt and the template file that produced the keyword index page. It didn't support sub-entries and also did not use a SQLite database; it just loaded the doc of each file in a given pagetree looking for index entries. The upside of using a database is that it is faster.

Pollen has no built-in facilities for building a keyword index for HTML; each author must design and implement their own system. It's quite an exercise. (Obviously, if you’re only targeting PDF via LaTeX, you can just use LaTeX’s system for this) I have written a pretty good one for an upcoming project. Here’s an [example of the output](https://thelocalyarn.com/excursus/test/keyword-index.html). It supports sub-entries using `!` as a separator, with the idea that it will plug into LaTeX pretty easily if I need it to. Roughly: * In HTML, my `◊index` tag function calls [`html-index`](https://thelocalyarn.com/code/artifact?udc=1&ln=110-117&name=d9318d9822c88d35), which produces a link to the keyword index page with a [custom attribute](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes) `data-index-entry` as a kind of marker so it can be found again in the next step. * My site uses a SQLite database to cache a bunch of stuff about each article each time it is rendered. (I decided to have a bit of fun and call this “crystalization”) As part of this process, the [`crystalize-index-entries!`](https://thelocalyarn.com/code/artifact?udc=1&ln=380-400&name=0131cbe3a0fd627f) function is called, which finds all links with a `data-index-entry` attribute, and saves info about them into the `keywordindex` table of the database. * The program which generates the index is [`keyword-index.rkt`](https://thelocalyarn.com/code/artifact/433d5c8d1f24446b). * Because each article also has its own row in the database, I can use the `rowid` column to simulate page numbers in the output. A few years ago I prototyped another system which was much simpler. See [these lines in `pollen.rkt`](https://github.com/otherjoel/try-pollen/blob/master/pollen.rkt#L366-L415) and [the template file that produced the keyword index page](https://github.com/otherjoel/try-pollen/blob/master/template-bookindex.html.p). It didn't support sub-entries and also did not use a SQLite database; it just loaded the `doc` of each file in a given pagetree looking for index entries. The upside of using a database is that it is faster.
ghost commented 5 years ago (Migrated from github.com)

Hi!

Thank you for your help!

The example of the output for your upcoming project is really beautiful, unfortunatly I am a newbie and didn't understand very well how to do this... Maybe in the future (=

Pollen is awesome!

Hi! Thank you for your help! The example of the output for your upcoming project is really beautiful, unfortunatly I am a newbie and didn't understand very well how to do this... Maybe in the future (= Pollen is awesome!
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen-users#10
Loading…
There is no content yet.