Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [asciidoc-lang-dev] Whitespace handling

On Fri, 26 Feb 2021 at 04:04, Sylvain Leroux <sylvain@xxxxxxxxxxx> wrote:
I noticed `asciidoctor` preserves whitespaces that aren't markups:

sh$ asciidoctor -b docbook - << EOF
abc   def

<?xml version="1.0" encoding="UTF-8"?>
<article xmlns=""
xmlns:xl="" version="5.0" xml:lang="en">
<simpara>abc   def</simpara>

You can see the three spaces in `abc   def` have survived within the
output, as well as the newline between `ghi` and `jkl`.

Some constructs, eg listing and literal blocks, have the semantic of maintaining the input so they must keep whitespace/line breaks as is.

For other things I suspect its this way because Asciidoctor originally intended to generate the same output as Asciidoc Python, which probably didn't change whitespace probably so that it didn't have to decide which constructs were literal and which were not.

Is preserving whitespaces a requirement? Or is the processor free to
replace any whitespace sequence with another at its convenience in the
output document? Should the original whitespaces be preserved in the DOM?

It is probably worthwhile keeping whitespace in the DOM since custom processing and extensions may consider a block literal.

But the output generators may change it, eg PDF justification is going to ignore input line breaks and spacing.  But for things like HTML or docbook its not necessary to change it, so its less clear what benefit there would be.


- Sylvain Leroux

asciidoc-lang-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top