This is free, open-source software! If you use asciidoctor-multipage, please consider sponsoring or contributing in some other way. Thank you!
asciidoctor-multipage is an extension for Asciidoctor that adds a configurable multipage HTML converter. It extends the stock HTML converter to generate multiple HTML pages from a single, large source document. The behavior is similar to a printed book where top levels (such as parts and chapters) are separated by page breaks (and perhaps blank pages) and lower levels (such as sections and subsections) are all included in a single chunk with styled headers to establish a visual hierarchy within the chunk.
This extension has also been used to generate a hierarchical website (from a content perspective, essentially multiple documents) from a single Asciidoctor document. While in some cases this might work fine (and you are free to use it this way), please understand that it is designed to work with a single, well-structured Asciidoctor document rather than as a website generator.
For an example of this extension in use, see https://owenh.net/nxlog-user-guide.html.
- Generates a root (top level) landing page with a list of child sections.
- Generates branch (intermediate level) landing pages as required, each with a list of child sections.
- Generates leaf (content level) pages with the actual content.
- Allows the chunking depth to be configured with the
multipage-leveldocument attribute (the default is 1—split into chapters).
- Supports variable chunking depth between sections in the document (by
multipage-levelattribute on individual sections).
- Uses section IDs to name each page (eg. "introduction.html").
- Supports cross-references between pages.
- Generates a full Table of Contents for each page, but with relevant entries only (the TOC collapses as required for each page).
- Includes a description for each section on the branch/leaf landing pages
descattribute, if set).
- Generates previous/up/home/next navigation links for each page.
- Allows the TOC entry for the current page to be styled with CSS.
- Supports standalone and embedded (--no-header-footer) HTML output.
- Retains correct section numbering throughout.
Notes and limitations
- Footnotes are currently not supported. See issue #3.
--template-diroption is currently not supported. See issue #19.
This extension is published on RubyGems as asciidoctor-multipage. Install the gem by adding it to your project's Gemfile or gemspec and running Bundler. Or install it directly:
$ gem install asciidoctor-multipage
gem install --user-install asciidoctor-multipage to install the gem in
your user's home directory.)
Be sure to use Asciidoctor v2.0.11 or later.
$ asciidoctor -V Asciidoctor 2.0.11 [https://asciidoctor.org]
The following command generates HTML output from a sample document; view the
output by loading
test/out/sample.html in a browser.
$ asciidoctor-multipage -D test/out test/black-box-docs/sample/sample.adoc
Alternatively, use Asciidoctor's
--require option like this:
$ asciidoctor -r asciidoctor-multipage -b multipage_html5 \ -D test/out test/black-box-docs/sample/sample.adoc
desc attributes are the most important for using
this extension. For an example of the these attributes in use, see
test/black-box-docs/sample/sample.adoc. These attributes work as follows:
multipage-leveldocument attribute specifies the section level at which the book is split into separate pages. The value should be an integer and matches the Asciidoctor levels. Note that as a physical book would normally only have page breaks for the top one or two levels in the hierarchy (such as part and chapter or chapter and section), a
multipage-levelvalue greater than 2 is generally not recommended.
0splits into parts (h1),
1splits into chapters (h2)—the default,
2splits into sections (h3), etc.
multipage-levelsection attribute specifies the section level to use for splitting the children of that section only. The integer given must be equal to or greater than the values of all parent levels.
descsection attribute can be used to provide a description for a section when it is listed on its parent landing page.
Some additional attributes are available for customizing the extension's behavior:
- Set the
multipage-disable-cssdocument attribute if you are using a custom stylesheet. You will need to include your own rules for styling the elements that are specific to multipage output. The default behavior (without this attribute set) is to add a few CSS rules in the document header just after the regular stylesheet—whether linked or embedded, default or custom—using an automatically registered DocinfoProcessor extension.
- To change the navigation labels, use
multipage-nav-next-labeldocument attributes. See
Other ways to contribute:
- Share this project with someone else who may be interested
- Contribute a fix for a currently open issue (if any) using a GitHub pull request (please discuss before working on any large changes)
- Open a new issue for a problem you've discovered or a possible enhancement
Thank you for your support! ✨
- To install dependencies, run
- To run tests, run
bundler exec rake.
- To run only a specific black-box document test, run
bundler exec rake test BB_TEST_ONLY=sample, where
sampleis the name of the test to run.
- When code modifications are expected to cause a change in HTML output, or
when a new black-box test is added, run
bundler exec rake test BB_UPDATE_FILES=1to generate (or update) output HTML files for the black-box tests.
- To run tests against multiple versions of Asciidoctor:
bundler exec appraisal installto install dependencies and
bundler exec appraisal raketo run the tests.
- To execute Asciidoctor with the extension (in its present local state) for
bundler exec asciidoctor -r asciidoctor-multipage -b multipage_html5 -D test/out test/black-box-docs/sample/sample.adoc(for example).
- To build the current version, run
bundler exec rake build; the gem will be placed in the
- To release a new version:
- update the date in
.devfrom the version in
bundler lock, and commit the changes;
bundler exec rake release; and
- increment the version in
bundler lock, and commit the changes.
- update the date in
- To change versions of Asciidoctor to test against:
bundler exec appraisal generate --travis,
.travis.ymlusing the output from the previous command, and
- commit the changes.
Copyright and License
Copyright 2019-2022 Owen T. Heisler. MIT license.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This source code may be used according to the terms of the MIT license. You
should have received a copy of this license along with this program (see