Skip to content

Commit

Permalink
Merge pull request #31 from FlorianFranzen/bin
Browse files Browse the repository at this point in the history
Add bin/asciidoctor-multipage executable
  • Loading branch information
owenh000 authored Dec 7, 2021
2 parents 2515ebe + b05d0f0 commit 79f782c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ $ asciidoctor -V
Asciidoctor 2.0.11 [https://asciidoctor.org]
```

Use Asciidoctor's `-r` option to require `asciidoctor-multipage` and the `-b`
option to select the `multipage_html5` backend. The following command generates
HTML output from a sample document; view the output by loading
`test/out/sample.html` in a browser.
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 \
Expand Down
3 changes: 2 additions & 1 deletion asciidoctor-multipage.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ require "asciidoctor-multipage/version"

Gem::Specification.new do |s|
s.authors = ['Owen T. Heisler']
s.files = Dir['lib/*.rb']
s.executables = ['asciidoctor-multipage']
s.files = Dir['bin/*', 'lib/**/*.rb']
s.name = 'asciidoctor-multipage'
s.summary = 'Asciidoctor multipage HTML output extension'
s.version = AsciidoctorMultipage::VERSION
Expand Down
28 changes: 28 additions & 0 deletions bin/asciidoctor-multipage
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env ruby

# This executable is based on `bin/asciidoctor-pdf` from the
# asciidoctor/asciidoctor-pdf project. Please consult that file for
# potential updates.

require 'asciidoctor-multipage'
require 'asciidoctor-multipage/version'
require 'asciidoctor/cli'

options = Asciidoctor::Cli::Options.new backend: 'multipage_html5'

# FIXME (from asciidoctor-pdf) provide an API in Asciidoctor for sub-components to print version information
unless ARGV != ['-v'] && (ARGV & ['-V', '--version']).empty?
$stdout.write %(Asciidoctor Multipage #{AsciidoctorMultipage::VERSION} using )
options.print_version
exit 0
end

# FIXME (from bespoke) This is a really bizarre API. Please make me simpler.
if Integer === (result = options.parse! ARGV)
exit result
else
invoker = Asciidoctor::Cli::Invoker.new options
GC.start
invoker.invoke!
exit invoker.code
end
1 change: 1 addition & 0 deletions lib/asciidoctor-multipage.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding: utf-8

require 'asciidoctor'
require 'asciidoctor/converter/html5'

class Asciidoctor::AbstractBlock
Expand Down

0 comments on commit 79f782c

Please sign in to comment.