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


ghi
jkl
EOF
<?xml version="1.0" encoding="UTF-8"?>
<?asciidoc-toc?>
<?asciidoc-numbered?>
<article xmlns="http://docbook.org/ns/docbook"
xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
<info>
<title>Untitled</title>
<date>2021-02-25</date>
</info>
<simpara>abc   def</simpara>
<simpara>ghi
jkl</simpara>
</article>
```

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.

Cheers
Lex


- Sylvain Leroux

_______________________________________________
asciidoc-lang-dev mailing list
asciidoc-lang-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/asciidoc-lang-dev

Back to the top