Forum › Bugs

HTML5 nested headers

lundepm
I'm trying to generate PDF from HTML5 with nested headers <h1> in section/article.
It displays correct in Chrome and FF with smaller headers, but Prince does not.

Running: prince --input=html5 --media=screen test.html -o ~/html5test.pdf

Any ideas that can help, or isn't this supported?
  1. html5test.pdf19.4 kB
    result
  2. test.html1.3 kB
    nestedHeaders
mikeday
Prince doesn't have any rules for this in the default HTML style sheet, but you can add something like this:
article h1 { font-size: 24pt }
article article h1 { font-size: 18pt }
article article article h1 { font-size: 14pt }

lundepm
Thanks for the answer, but this won't help with the PDF outline (toc).
mikeday
You can do something similar to set the bookmark-level:
article h1 { prince-bookmark-level: 1 }
article article h1 { prince-bookmark-level: 2 }
article article article h1 { prince-bookmark-level: 3 }
...
lundepm
Okay, thanks.

I'll give it a shoot
dynnamitt
This is not a good solution.

The HTML5 spec has 4 sectioning elements. section , article , aside and nav .

It would give an INFINITE number of css rules to cover all options since
"each sectioning element can contain new sectioning elements"

Edited by dynnamitt

dynnamitt
I accept the PrinceXml html4 outline solution (using h1-h6),
and the prince-bookmark-level is a good HACK to use when you DONT have *good* html5

BUT if I DO have good html5, it shouldn't be my responsibility "to make things just work"

The princeXML implementation should internally handle sectioning elements as a special class for creating bookmarks in the outline -- automatically -- If the HTML5 flag is switched on

..otherwise: Don't brag so much about your html5 support.

"HTML5 is all about semantics"

Edited by dynnamitt

dauwhe
The default value of bookmark-level in CSS is none, so they are not generated automatically. Everyone's requirements are different—we don't want bookmarks in our PDFs.

I'm also lucky in having some control over our HTML, so we don't get infinitely nested sectioning elements. I had my fill of that in my Docbook days :)

Dave
mikeday
Right, CSS is not recursive, so it cannot apply style patterns to infinitely deep trees. However, few documents have more than six levels of headings, so most cases can be handled with a small collection of rules.

We could add some kind of "auto" value to the prince-bookmark-level that would infer the appropriate level based on its position in the hierarchy. However, this can be done already using JavaScript, and we have many other demands on our time at this moment, like improving JavaScript support. :)
dynnamitt
I guess Prince9 is just another user-agent not imlementing this part of the HTML5 spec:
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Sections_and_Outlines_of_an_HTML5_document