Installation and Update
There are two options to install Asciidoctor Question. The first is to use gem install
on the command line:
$ gem install asciidoctor-question
The second is to add the following entry to your project’s Gemfile.
gem 'asciidoctor-question', '~> 0.5'
and execute bundle
in the command line.
$ bundle
To update asciidoctor-question
type
$ gem update asciidoctor-question
Creating a Question
A question is written inside a literal block, which needs two attributes.
[question, question-type] // <b class="conum">(1)</b> <b class="conum">(2)</b>
.... // <b class="conum">(3)</b>
Question in appropriate syntax
....
-
The first positional attribute in the attribute list specifies that this block is a question.
-
The second positional attribute defines the type of this question (mc or gap)
-
Place the attribute list directly on top of the delimited literal block (....). You can also use an example (====) or open block (
--
) as an alternative.
The following question types are available:
Question Type | input | output |
---|---|---|
mc |
|
|
gap |
|
Generating a Question Document from a Terminal
You can load Asciidoctor question in a terminal using the -r
flag.
$ asciidoctor -r asciidoctor-question sample.adoc
You can also use Asciidoctor question with other converters, such as Asciidoctor PDF.
Asciidoctor-pdf is also loaded with the -r
flag.
$ asciidoctor -r asciidoctor-question -r asciidoctor-pdf -b pdf sample.adoc
Or, you can invoke Asciidoctor and the PDF converter with the asciidoctor-pdf
command.
The command implicitly sets the -r
and -b
flags for PDF output.
$ asciidoctor-pdf -r asciidoctor-question sample.adoc
Advanced Usage
Generating PDF with solutions
With the attribute :solution: it is possible to generate a pdf file which contains the questions with its solutions.
$ asciidoctor -r asciidoctor-question -r asciidoctor-pdf -b pdf -a solution sample.adoc
You can also add the :solution:
attribute to your asciidoc file.