asciidocasciidoctor

Is there a way to have not formatted text block in Asciidoc?


Does it exist in Asciidoc (rendered by Asciidoctor) a way to have a block of text where asciidoc formatting is not applied, but it keeps the asciidoc paragraph format (background color, font, font color, etc...) and not preformated format ?

My specific problem

I have a paragraph that I want to render "as I type it"

Array(Element1, Element2, Element3)

Currently, it renders as follow:

actual output

And I want to render it as follow:

Expected Output

What I've tried so far

I tried to use code block or literal block, but text appears as preformated, which I don't want:

----
Array(
  Element1,
  Element2,
  Element3
)
----

Or

[literal]
....
Array(
  Element1,
  Element2,
  Element3
)
....

Gives me the following output:

attempts


Solution

  • I managed to get what I want by using [%hardbreaks] option to keeping line breaks and by using {nbsp} built-in attribute for non-breaking spaces.

    Here is the complete code:

    [%hardbreaks]
    Array(
    {nbsp}{nbsp}Element1,
    {nbsp}{nbsp}Element2,
    {nbsp}{nbsp}Element3
    )