anubis
anubis

Reputation: 1505

How write some html code inside a listing block in asciiDoctor?

It is possible to add dome html code inside a listing block?

I have a file like:

----
Blablabla
+++<b>This has to be interpreted as HTML</b>+++
<span>This has not to be interpreted as HTML but as TEXT</span>
----

This is printed so:

Blablabla
+++<b>This has to be interpreted as HTML</b>+++
<span>This has not to be interpreted as HTML but as TEXT</span>

But it should be printed so:

Blablabla
This has to be interpreted as HTML
<span>This has not to be interpreted as HTML but as TEXT</span>

Somebody has an idea how to achieve that?

Upvotes: 1

Views: 453

Answers (1)

eskwayrd
eskwayrd

Reputation: 4521

Code blocks disable most Asciidoctor substitutions by default. But you can control which substitutions should be enabled for any specific block.

For your example, add the [source,subs="+macros"] line before your code block:

[source,subs="+macros"]
----
Blablabla
+++<b>This has to be interpreted as HTML</b>+++
<span>This has not to be interpreted as HTML but as TEXT</span>
----

For more information on substitutions, see: https://asciidoctor.org/docs/user-manual/#subs

Especially: https://asciidoctor.org/docs/user-manual/#applying-substitutions

Upvotes: 1

Related Questions