Gregg
Gregg

Reputation: 35884

Can Asciidoctor render a separate HTML page per chapter?

If I have something like the following:

The Manual
====================
Gregg Bolinger
v1.0, 2014-15
:doctype: book
:icons: font
:imagesdir: images

Preamble paragraph

include::chapter1.ad[]

include::chapter2.ad[]

I'd like so that each chapter renders in its own HTML file and is linked to from the TOC rather than everything being in a single book.html, for example. It seems to generate separate files already, but that's only because they are in the source directory. It is still combining everything into a single HTML page. I'm using the Gradle Asciidoctor plugin, if that helps to know.

Upvotes: 8

Views: 3185

Answers (3)

eskwayrd
eskwayrd

Reputation: 4521

As Sam Macharia answered, asciidoctor-multipage can achieve your goal.

Also, most Docbook toolchains let you control how content is "chunked" into HTML pages, including at the book, chapter, and section levels.

Antora is the "official" way to achieve your goal.

Upvotes: 0

Sam Macharia
Sam Macharia

Reputation: 1251

Using the asciidoctor-multipage extension, each chapter can be rendered in its own HTML file. The links in the TOC points to the respective HTML chapters rather than everything being in a single book.html. At the end of every HTML page, the extension also adds links to the next or previous page, as seen on this website.

Assuming you have already installed the asciidoctor, just do $ gem install asciidoctor-multipage in your command line to install the multipage extension.

After making your file-name.adoc with various chapters, $ cd to that folder and then do $ asciidoctor -r asciidoctor-multipage -b multipage_html5 -D test/out --backend multipage_html5 -a data-uri file-name.adoc. This command will embed any images in the file-name.adoc to the new .html files which will be saved in newly created test/out folder. I only tested this using Ubuntu 20.04.

Upvotes: 0

LightGuard
LightGuard

Reputation: 5378

Unless there's something in the gradle plugin that does chunked html, asciidoctor does not handle chunked output at the moment. It's on the list of things to do, but it hasn't been done. If you look at the issue, however, someone has create a custom script/converter to do it though, perhaps that will work for your case as well.

Upvotes: 3

Related Questions