Scrivener to HTML with preset Stylesheets

Taking a new project with the default preset styles, and then compiling it to HTML, i find the following quite interesting:

the TITLE preset compiles to H1 in html
the HEADING preset compiles to H2 in html
the SUBHEADING preset compiles to H3 in html

…and all other presets compile to P.x (where x is a number) in html.

This makes me wonder whether it would be possible for a user to create presets that would compile to H4, H5, and H6 in html?

If it is not possible for a user to do so, would it be possible to include such presets (sub-subheading, sub-sub-subheading, sub-sub-sub-subheading as awkward but logical possible names for the presets) in future versions of Scrivener?

thanks - asotir

I’m not positive, but I think that’s just hard-coded in. The compiler looks for the default formatting presets and does something special with them if they are encountered.

What I would recommend instead is familiarising yourself the Formatting compile option pane. With the compiler set to HTML, if you click on the various icon types (and optionally, indent levels) in the top half of that pane you can click on the title text in the mock editor and assign an HTML header level with the drop-down menu supplied there. Note how if you click in the body text of the mock editor (assuming you are viewing an icon type that has both Text and Title checked off), then you’ll see it switch to “Body text”.

So this is where you could add level specific formatting, like which HTML header level to use, when compiling. This will use your Binder names to print the titles, rather than having them typed into the editor itself. This will be a better way to work if you require a lot of flexibility.

Wonderful. Never looked into that before; it is just what I was asking for, and is much more flexible. Thanks!

  • asotir

Great, yeah I think it’s a good way to manage headers. It means your outline becomes a bit more rigid, having to match the book a bit closer, but for non-fiction that suits me. But especially if you want to number them, it’s much easier to just do that in Formatting and forget about numbers while writing.

This has got me thinking about the philosophy of Scrivener again. What I have been trying to do is work with headers and structure within a single document. But Scrivener is really set up to create structure across several documents, a structure that is shown in the Binder.

I have to force myself to break up my work into smaller chunks, then, as this will allow me to create more depth within the Binder documents and then use the Compiler to set level-based titles to the various header levels in HTML.

– asotir

Do what works best for you. That is one way of using the software—I prefer it myself, but there are other ways. For instance you can embed raw HTML into the ultimate output if you do not otherwise need the Preserve Formatting field. In the HTML Options compile pane, you can set any text within a Preserve Formatting block to be passed through as raw HTML. So you could do headers that way as well, if breaking things down to the smallest section’s level of content is a bit much for your working style. You could even do a blend; have Binder outline down to the section level, but leave sub- and subsubsections as typed in HTML code around the titles.