Repository navigation
Description
(Opus 5.5)
What the reader sees
The same component shows different whitespace depending on how Citry sends the page. Vue's template compiler condenses whitespace; Citry's Python template rendering keeps the authored text exactly. Take this template:
<p>
<a href="#">one</a>
<a href="#">two</a>
</p>
Observed (attributes shortened) on the current development branch (citry-benchmark-design, 2026-09-28):
| How the page is sent | HTML for the paragraph | Visible text |
|---|---|---|
Hydrated (component has js, server writes Vue's render) |
<p><a>one</a><a>two</a></p> |
onetwo |
Hydration declined, for example a custom on_dependencies hook (reason="custom-hooks") |
\n<p>\n <a>one</a>\n <a>two</a>\n</p>\n until Vue mounts, then Vue's version |
one two, then onetwo |
Static output (component without js) |
same as the Python HTML above | one two |
Vue drops a whitespace-only text between two elements when it contains a newline, so the links touch. The Python HTML keeps the newline, which the browser shows as one space.
Other differences found in the same check:
<textarea>: Vue condenses the content ("\n t\n"becomes" t "), while the Python HTML keeps it. The field's initial value differs between static output and a Vue page.<pre>on a hydrated page is written as adata-allow-mismatch="children"shell holding Python's HTML, and Vue builds its content in the browser. It hydrates correctly, but it is a shell only because of whitespace.
What is already consistent
- Hydrated pages: the Rust server render programs run Vue's compiled render functions, so the server HTML and Vue's first render match exactly, whitespace included.
ssr=Falseand pages belowssr_element_thresholdsend an empty mount element, so there is nothing to flash.- Text produced in Python (
{{ value }}) and<c-raw>/MarkupHTML are written unchanged on every path. Vue does not condense values set through bindings either. - No whole-document whitespace pass runs per render any more.
serialize.py,_vue/serialization.pyandcitry_html_transformcontain no whitespace rewrite. One leftover:_vue/compiler.pystill validates the compiler'sauthored_text_plan(thecondense.whitespace/condense.drop-whitespaceactions) and stores it onCompiledRender, but no code reads it. It runs once per compile, not per render.
So the remaining difference is between Vue's whitespace rules and Python's template rendering. It shows up in two places: a page Vue replaces when it mounts (visible text shift), and a component rendered without JS compared with the same component rendered by Vue.
Options the maintainer proposed
- A setting, on by default, that condenses whitespace the way Vue does when Citry renders a template in Python, so the output matches Vue. The setting can be turned off to keep authored whitespace. The Rust Vue compiler already reports which authored text Vue condenses or drops (
authored_text_plan), so Python could apply the same actions at compile time, not per render. - Require
<c-raw>to print whitespace exactly as written, and condense everything else. - Follow Vue's exceptions: keep whitespace inside
<pre>(Vue also drops the first newline after<pre>), and keep<script>/<style>content as written (Vue templates do not render these tags). Note that Vue does condense<textarea>.
Options 2 and 3 can combine with option 1: option 1 decides the default, and 2 and 3 decide where authored whitespace survives.
Error modes to decide
- Setting has an invalid value: a non-bool should raise
TypeErrorwhenCitrySettingsis created, likessr. - Setting is off but the page hydrates: hydrated HTML comes from Vue's compiled render and is condensed anyway. Either the setting also switches Vue's compiler to
whitespace: "preserve"(so both sides keep whitespace), or the docs state that the setting only affects Python-rendered output. A setting that only changes one side reintroduces the text shift. - CSS
white-space: pre/pre-wrapon a normal element: the compiler cannot see CSS, so condensed text renders differently from the authored source. Vue has the same limit; the docs should say to use<pre>or<c-raw>. - Whitespace inside
<c-raw>or aMarkupvalue: stays exactly as written in every mode. - Text that spans a component boundary or a slot fill: the rule must give the same result whether Python or Vue renders the parent, or the declined-page flash remains for slots.
Acceptance
For each template in a small set (inline elements separated by newlines, <pre>, <textarea>, slots, <c-raw>), the static output, the declined-hydration server HTML, and Vue's browser render produce the same text nodes.
Activity
docs(design): record the maintainer's decisions on whitespace parity …
docs(design): whitespace parity (#152) and script order (#145) for 0.…
JuroOravec commentedon Nov 14, 2026
Moved to after 1.0.0 (label
v1.1). The design needs a patched vize crate, compiler output changes and a citry-core release, and #624's decision 2 keeps exact whitespace outside the 1.0 stability promise.chore: prepare the Citry 0.9.0 release (#685)