Substitution for each text block

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

Substitution for each text block

minitoma
Hello guys,

is it possible to set a substitution to a text block style such as literal block without explicitly write it on each block.
I would like to know if there is some kind of attribute or a way to do something like.

= Title
:value: 42
:literal-subs: normal

- text

    lalala

    my value is :value:

- text2

    lalala

    value is still :value:

so i would not have to set

[literal, subs="normal"]

on each block

Thomas
Reply | Threaded
Open this post in threaded view
|

Re: Substitution for each text block

mojavelinux
Administrator
You can accomplish this using a Treeprocessor. Just visit each of the literal blocks and change the subs property. You can use this extension as a starting point: https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/shell-session-treeprocessor/extension.rb

To set the subs, you need to use:

block.subs.replace [:normal]

I've thought about the idea of adding a global switch to the syntax, but I'm concerned it would break portability and be hard for tooling to support properly. It's better to be explicit.

Cheers,

-Dan

On Fri, Apr 21, 2017 at 3:50 AM, minitoma [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hello guys,

is it possible to set a substitution to a text block style such as literal block without explicitly write it on each block.
I would like to know if there is some kind of attribute or a way to do something like.

= Title
:value: 42
:literal-subs: normal

- text

    lalala

    my value is :value:

- text2

    lalala

    value is still :value:

so i would not have to set

[literal, subs="normal"]

on each block

Thomas


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Substitution-for-each-text-block-tp5523.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