Asciidoctor HTMLBook is an Asciidoctor backend for converting AsciiDoc documents to HTMLBook documents.
Add this line to your application’s Gemfile:
gem 'asciidoctor-htmlbook'
And then execute:
$ bundle
Or install it yourself as:
$ gem install asciidoctor-htmlbook
$ asciidoctor-htmlbook basic-example.adoc
or
$ asciidoctor -r asciidoctor-htmlbook basic-example.adoc
For more options:
$ asciidoctor-htmlbook -h
To use Asciidoctor in your application, you first need to require the gem:
require 'asciidoctor/htmlbook'
Load from file:
doc = Asciidoctor.load_file 'mysample.adoc', backend: 'htmlbook'
puts doc.convert
Convert file:
Asciidoctor.convert_file 'mysample.adoc', backend: 'htmlbook'
Load from string:
doc = Asciidoctor.load '*This* is Asciidoctor.', backend: 'htmlbook'
puts doc.convert
Render string:
Asciidoctor.convert '*This* is Asciidoctor.', backend: 'htmlbook'
When rendering a string, the header and footer are excluded by default to make Asciidoctor consistent with other lightweight markup engines like Markdown. If you want the header and footer, just enable it using the :header_footer
option:
Asciidoctor.convert '*This* is Asciidoctor.', backend: 'htmlbook', header_footer: true
You can overwrite default templates by adding :template_dir
option:
Asciidoctor.convert '*This* is Asciidoctor.', backend: 'htmlbook', template_dir: 'path/to/templates'
Note
|
asciidoctor-htmlbook template do not compatible with asciidoctor built-in template backend. View ./templates for more info. |
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/rake
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/chloerei/asciidoctor-htmlbook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.