Asciidoc macros

I use asciidoc to render text.

I find it hard to understand macros

My goal is simple macro processing (e.g. in LaTeX)

FOO should be replaced by "bar"

MYTEXT (xyz) should be replaced by: "This is my zyz text!"

(maybe in another way pass the parameter "xyz")

Example abc.txt file:

text text text FOO text FOO text text text MYTEXT(jajaja) 

This should lead to

 text text text bar text bar text text text This is my text jajaja! 

I would expect the definition of FOO and MYTEXT to go into the abc.conf file; Probably in the series [macro].

Additional question:

Are there problems with pattern matching if

Should FOO be replaced by "bar" and FOOX "barbar"?

+6
source share
1 answer

In order to substitute FOO in bar and FOOX in barbar, I would use the substitution syntax:

 = AsciiDoc title :FOO: bar :FOOX: barbar Regular text here using substitutions: {FOO} is bar and {FOOX} is barbar. 

As you can see, you declare the replacement as :VARIABLE: and use it as {VARIABLE} .

As for the actual creation of new macros, macros usually have the type macroname:content[Text input] . They are documented here for the AsciiDoc Python project and, ultimately, here for the AsciiDoctor ruby ​​project, but I never used them, I prefer replacements and conditional blocks.

+4
source

Source: https://habr.com/ru/post/907101/


All Articles