Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single HTML file for print? #588

Closed
tgraham-antenna opened this issue Aug 23, 2021 · 2 comments
Closed

Single HTML file for print? #588

tgraham-antenna opened this issue Aug 23, 2021 · 2 comments

Comments

@tgraham-antenna
Copy link
Contributor

Is there an existing mechanism to generate a whole-book HTML file for print formatting?

I would like to try 'electric-book' with AH Formatter (https://www.antennahouse.com/formatter-v7), but I really need a single HTML file for the whole book. So far I've previewed some of the sample's chapter files in the AH Formatter GUI, but I haven't made a PDF of the whole document.

From what I've seen, the HTML files all use the same CSS files, so that doesn't look like an impediment to making a single file. Is there a way?

@arthurattwell
Copy link
Member

Hi @tgraham-antenna, and thank you for this and your other PRs! I really appreciate it so much.

There isn't an existing mechanism for this, I'm afraid. We have discussed it at EBW, for instance in our experiments with Paged.js, which also needs a single HTML file. Another reason we'd like to have this mechanism is, oddly enough, for web-output purposes. If we could concatenate HTML files for PDF output, we could also edit book parts (e.g. subchapters) in smaller markdown files, and publish shorter web pages. But since we can't afford to have page breaks between sub-chapters in PDF, we're stuck with enormous chapter pages on the web. Shorter web pages would be better for web readability and for SEO and search.

So far, we have been assuming that we want a single <html> element in that concatenated HTML file for it to be valid. Given that, we know of at least two challenges we need to overcome in order to concatenate HTML files:

  1. We use attributes on the <body> element extensively. For instance, a contents page has a contents-page class on the body element, and a chapter the chapter class. We would need to move all of those to a wrapper element inside <body>. This is theoretically doable. There's an old experimental branch here where I did this for Paged.js, which (at the time at least) didn't pick up classes on the body element. We'd need a more robust approach than that to handle more than just classes -- probably some kind of JS-driven approach or a deeper restructuring of _includes/head.html and related CSS.

  2. If we concatenated HTML files, we would have to resolve duplicate IDs somehow. In TOCs and elsewhere, we use relative, internal links as cross references. For instance, if two separate markdown files link to the heading 'Conclusion', both would use the same ID #conclusion. So the concatenation process would have to update these IDs both where they're defined and in any links that point to them (e.g. by appending a prefix or suffix). That seems theoretically doable to me (and I've seen it work elsewhere, e.g. in the Sigil epub editor), but I don't know if we'll see curveballs during implementation.

If you have further thoughts or ideas for other approaches to this, that would be great. Internally, we have a wishlist for a future version of the Electric Book template, and this is on it.

@arthurattwell
Copy link
Member

Housekeeping long-unattended issues.

We introduced the output of a single HTML filed (merged.html) in #640.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants