Login  Register

Single PDF and multiple HTML from same sources

Posted by afrey on Feb 13, 2020; 10:05am
URL: https://discuss.asciidoctor.org/Single-PDF-and-multiple-HTML-from-same-sources-tp7640.html

Hi!

I have a set of .adoc sources that together make a book (chapters, subsections, etc). I need to generate both HTML and PDF from them, but the output I'm trying to achieve is:
- a single PDF output file
- one HTML file per source .adoc, as I have found that this is the best user experience

Has anyone already achieved that?

If not, I'm considering the following solution:

- implement an include processor to support a syntax like this:
   include::xref:<path to subdoc>[]
- this include will be expanded in two different ways depending on the backend:
   - for HTML, to "xref:<path to subdoc>[]"
   - for PDF, to "include::<path to subdoc>[]"
- this would allow me to write my top-level and chapter documents using the special include::xref: syntax to reference the subsections, which will be transformed in links for HTML and in the actual section content for PDF.
- additionally, the regular cross-document xrefs would also have to be somehow adjusted, using a macro preprocessor, so that the anchors are "globalized" with the document name when I generate the single PDF document.

Do you think I'm on the right path? Also, should this kind of flow be supported in the core?

Best regards,
-- Alex