Whitespaces are empty spaces and newlines that visually separate other characters and items. These whitespaces are not always allowed or preserved in Serna.
Whitespace handling is governed by the XSLT stylesheet and depends on the Document Type.
There are three major aspects of whitespace handling in the editor:
Parsing the DTD
If the document is opened with a DTD, element-only content is whitespace stripped.
XSLT Processing
Whitespaces are preserved or stripped according to the xsl:strip-space and xsl:preserve-space top-level instructions of the stylesheet, and to xml:space attributes in a particular document, exactly following the procedure specified in XSLT 1.0 standard. By default, whitespaces are preserved.
white-space-treatment
white-space-collapse
linefeed-treatment
By default, consecutive whitespaces are simplified to a single whitespace. However, these properties can be set so that it will become possible for the user to insert whitespaces and newlines as in a conventional word editor. There are also some elements that allow the insertion of newlines and contiguous spaces, e.g. <programlisting> Docbook element, <codeblock> DITA element.
Figure 1. <programlisting> Docbook element lets you insert spaces and newlines freely.
Serna does its best to save the document pretty-indented for readability in text editors and the Text mode, at the same time obeying whitespace handling rules. The following rules apply:
If the stylesheet specifies that whitespaces are preserved for an element, whitespaces are preserved for that element, and the element content is not indented.
If the element is not specified in the stylesheet as whitespace-preserved, the element content is pretty-indented.