What it keeps
- Text is never rewrapped. Multi-line element text keeps its own layout and moves to the new indent as a block. That is safe because KScript removes the indentation that the lines of element text share, so
<echo>prints the same thing. - Attribute values are kept exactly as written, including values that span several lines.
- Comments are kept; a multi-line comment moves as a block.
- Raw content is kept exactly, trailing spaces included: CDATA sections, and in pages the content of
<pre>,<textarea>,<script>and<style>.<markdown>keeps its trailing spaces (two spaces at the end of a line are a line break in Markdown). Add your own elements toformat.preserve, or use the ignore comments. - Pages render the same. Inline elements written side by side (
<b>a</b><i>b</i>) stay together. An inline tag can spread its attributes across lines while preserving the text and spaces around it, including in a row of links or in a sentence. Between elements, a line break only goes where there was already whitespace or next to a block-level element such as<div>or<li>. In script elements whose content is text, such as<echo>, no whitespace is added between child elements either. <!doctype>,<?xml ?>, a byte order mark and the file's line endings (unlessend_of_linesays otherwise) are kept.
A file with markup errors (an unclosed element, a stray <) is left alone: kscript fmt reports the first error and exits 1, and the editor makes no change. Fix the error, which kscript check and the editor also show, and format again.