Asciidoctor/PDF - Add line breaks for replaced attributes

1.2k Views Asked by At

We have the following template to generate a PDF:

== Overview

{dynamic_tables}

The dynamic_tables attribute shall be replaced with text that represents a table. It has to be dynamically generated, as we can't know how many tables and how many rows there are.

I tried to just pass in the text for the tables (also with \n for line breaks), but asciidoctorj always make on line out of it and therefore fails to render a table.

How do I insert line breaks into a value, that is then passed into an attribute like {dynamic_tables} to render line breaks? I tried a couple things (like \n or +) but they are just inlined as well (\n being "ignored").

1

There are 1 best solutions below

0
On

You will need a + and a line break. Within an attribute assignment, a single line break ends the assignment, but a backslash followed by a line break becomes an actual line break. So within an asciidoc file, try this:

:dynamic_tables: first entry + \
second entry + \
third entry

The asciidoc code

== Overview
{dynamic_tables}

should then render like

== Overview
first entry +
second entry +
third entry

However I don't know whether and how it is possible to assign multi-line values on command line or with the API.