content reuse and manipulation

classic Classic list List threaded Threaded
2 messages Options
kev
Reply | Threaded
Open this post in threaded view
|

content reuse and manipulation

kev
Given the following Asciidoctor snippet
Questions:
. What are the possible types of products in a neutralization reaction?
. What are the different types of bases?

Answers:
. What are the possible types of products in a neutralization reaction? (salt, water, CO~2~, hydrogen)
. What are the different types of bases? (metal hydroxides, metal oxides, metal carbonates, metals)
What is the best way in Asciidoctor so that the questions are not repeated in the answers in the Asciidoctor source? Block content can only be reused via including an external file AFAIK but that still leaves the problem of adding the answers depending on the context. I could use hacky preprocessor directives and attributes or pre-process the text via a script but I hoped for a cleaner method.
Reply | Threaded
Open this post in threaded view
|

Re: content reuse and manipulation

mojavelinux
Administrator
kev,

I'd recommend using attribute references (which can hold up to a single paragraph of content).

:q-1: What are the possible types of products in a neutralization reaction?
:q-2:  What are the different types of bases?

Questions:
{q-1}
{q-2}

Answers:
{q-1} (salt, water, CO~2~, hydrogen)
{q-2} (metal hydroxides, metal oxides, metal carbonates, metals)

If the questions have a natural key (like an ID), then you can base the attribute names on the key instead of using numbers.

Cheers,

-Dan

On Thu, Feb 28, 2019 at 2:33 AM kev [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Given the following Asciidoctor snippet
Questions:
. What are the possible types of products in a neutralization reaction?
. What are the different types of bases?

Answers:
. What are the possible types of products in a neutralization reaction? (salt, water, CO~2~, hydrogen)
. What are the different types of bases? (metal hydroxides, metal oxides, metal carbonates, metals)
What is the best way in Asciidoctor so that the questions are not repeated in the answers in the Asciidoctor source? Block content can only be reused via including an external file AFAIK but that still leaves the problem of adding the answers depending on the context. I could use hacky preprocessor directives and attributes or pre-process the text via a script but I hoped for a cleaner method.



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/content-reuse-and-manipulation-tp6766.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux