Daniel Darabos
Daniel Darabos

Reputation: 27455

Multi-paragraph attribute in AsciiDoc

I have a two-paragraph text that gets repeated fairly often. How could I avoid the repetition?

For now I have:

:something-1: Blah blah blah +
blah blah blah +
blah blah blah

:something-2: Blah blah blah +
blah blah blah +
blah blah blah

And then:

--
{something-1}

{something-2}
--

Is there a way I could put both paragraphs into one attribute? It would be even better if I could put the block into the attribute too.

This doesn't work:

:something: Blah blah blah +
blah blah blah +
blah blah blah +
+
Blah blah blah +
blah blah blah +
blah blah blah

The plus on the empty line and the second paragraph are not parsed as part of the attribute definition.

Another option is putting the two paragraphs in a separate file and using the include: macro. But creating a separate file every time I face this problem would create some clutter. It also makes it harder than necessary to go from 1-paragraph definitions to 2-paragraph definitions. I'd rather have a single "glossary" section (or document) which contains all these repeated term definitions.

Upvotes: 1

Views: 404

Answers (1)

Daniel Darabos
Daniel Darabos

Reputation: 27455

I don't know if multi-paragraph attributes are possible, but selective imports definitely are! I now have a glossary.asciidoc file:

tag::something[]
--
Blah blah blah

Blah blah blah
--
end::something[]

And I can import this section by saying:

include::glossary.asciidoc[tag=something]

A major advantage of this approach is that text formatting inside the snippet works.

Upvotes: 2

Related Questions