sillsdev / ptx2pdf

XeTeX based macro package for typesetting USFM formatted (Paratext output) scripture files
23 stars 8 forks source link

Add PDF outline character style #597

Open mhosken opened 2 years ago

mhosken commented 2 years ago

There are various situations where we want to add a PDF outline entry that isn't one of the automatically generated ones (chapter, etc.). I propose we use an attributed character style. For example:

\zoutline A useful point|indent="2"\zoutline*

The tricky part of this is coming up with an id. For example if we are in a strongs index, we don't have very good ids.

davidg-sil commented 2 years ago

Is this only going into the PDF outline? Or is it an extension to the tocline in #534 ? I'm suspicious of zoutline being a character style. To me character styles should be producing text on the page.

markpenny commented 2 years ago

@mhosken Has this need now been met by \zlabel? Or is there something else that this enhancement request will be able to do for us? Perhaps it is similar in behaviour, but has a different application which needs to be coded up to create the Outline elements of the PDF.

klassenjm commented 2 years ago

Would this also be like an ID/anchor. If so, using the USFM linking attribute 'link-id' might be an idea?

\jmp John the Baptist|link-id="article-john_the_baptist"\jmp*

Maybe then an additional attribute to indicate that this ID should appear as a bookmark?

(Or it could be a milestone.)

Getting a little off-topic: Might it be a good to ask the PT team what their current thinking is about improving linking support in PT? This is a topic of interest there while work on study Bible support is being done.

davidg-sil commented 2 years ago

This sounds like a good concept, yes. In fact, if there is a good, unique, attribute name, then it could be treated as a reserved attribute, used on any character style (or milestone) to the same effect.

An idea I've just had was index-entry, since something that's worthy of putting into an outline is presumably worth adding to a printed index.

But maybe that would over-crowd the outline. Perhaps 'outline-entry' and 'index-entry' as 2 separate attributes, where an outline-entry (by default) also creates an index entry, but an index-entry?

davidg-sil commented 1 year ago

Some more discussion is probably relevant. Has anyone had more thoughts on this?

davidg-sil commented 1 year ago

My current thought is: \jmp John the Baptist|link-id="article-john_the_baptist" outline-entry="John the Baptist" outline-level="2"\jmp* Where the the link-id provides a unique identifier for the PDF internals, "John the Baptist" is what goes in the outline, and the outline-level has 0 for book-level, 1 for chapter-level, and hopefully 2 is within the PDF spec...

davidg-sil commented 1 year ago

Hmmm,. thinking about it, I wonder if there's a case for outline-entry as above to be link-title?

klassenjm commented 1 year ago

Using link-title makes sense to me.

davidg-sil commented 1 year ago

OK... I have just extended the logic a little: link-title is supposed to generate hover text or similar if there's a supplied link-href for the link to link to. The behaviour is undefined, as far as I know when there's no link-href, or when a style with a link-href also has a link-id.

PTXprint now has the following logic:

If there's a link-id, then the text is always a possible target for another jump.

Also, if there's a link-href attribute to a character style:

If there's no link-href attribute:

If there is no link-id but outline-entry is specified, a warning should appear in the log, and there will be no entry in the outline.

davidg-sil commented 1 week ago

While not a character style (as it produces no characters, in and of itself), this has been implemented for a year, now. Can it be closed?