From 45b43dc2997e6867cfb49e47f433bcfe54c995a3 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 24 Aug 2026 22:54:54 -0400 Subject: [PATCH] fix: a
owns the newline beside it, like a comment --- .../src/printer/nodes/fragment_doc.rs | 14 +- docs/conformance_prettier_svelte.md | 2 +- .../expected.json | 695 ++++++++----- .../input.svelte | 18 +- .../prettier_variant_newline_after.svelte | 20 +- .../prettier_variant_newline_before.svelte | 20 +- .../prettier_variant_newline_both.svelte | 22 +- .../elements/void_br_newline/expected.json | 968 ++++++++++++++++++ .../elements/void_br_newline/input.svelte | 68 ++ .../unformatted_no_self_closing.svelte | 68 ++ .../void_br_newline/unformatted_spaces.svelte | 68 ++ 11 files changed, 1676 insertions(+), 287 deletions(-) create mode 100644 tests/fixtures/svelte/elements/void_br_newline/expected.json create mode 100644 tests/fixtures/svelte/elements/void_br_newline/input.svelte create mode 100644 tests/fixtures/svelte/elements/void_br_newline/unformatted_no_self_closing.svelte create mode 100644 tests/fixtures/svelte/elements/void_br_newline/unformatted_spaces.svelte diff --git a/crates/tsv_svelte/src/printer/nodes/fragment_doc.rs b/crates/tsv_svelte/src/printer/nodes/fragment_doc.rs index f7002f62d..8fb31d846 100644 --- a/crates/tsv_svelte/src/printer/nodes/fragment_doc.rs +++ b/crates/tsv_svelte/src/printer/nodes/fragment_doc.rs @@ -726,9 +726,17 @@ impl<'a> Printer<'a> { /// split, since breaking there would inject a rendered space.) So an inline sibling isolated /// by authored newlines flows back onto the content line, converging those authorings. /// - /// Four neighbours are excluded, none of them a mere spelling difference: + /// Five neighbours are excluded, none of them a mere spelling difference: /// - a **comment**, whose authored position is authorship — folding one into a text fill /// would relocate it across a semantic boundary (§Comment Position Philosophy); + /// - a **`
`**, which IS a rendered line break, so the source newline beside it mirrors + /// the render rather than spelling a space — the one licence this rule runs on. It is + /// line-owning exactly as a comment is: it BOUNDS the run without sterilizing it (the runs + /// on either side still flow), and its space spelling stays as authored (`text
text` + /// is never forced open). Prettier holds it too, so this is parity + /// (`elements/void_br_newline`; the bounding control is in + /// `inline_sibling_newline_flow_prettier_divergence`). The other void elements (``, + /// ``, …) render inline and flow like any inline element; /// - a **block element**, which owns its own line via `handle_block_child`; /// - a **blank line** (2+ newlines), a Tier-2 authoring signal, screened by the callers; /// - a **control-flow block** (`{#if}` / `{#each}` / `{#key}` / `{#await}` / `{#snippet}`), @@ -766,6 +774,10 @@ impl<'a> Printer<'a> { FragmentNode::ExpressionTag(_) | FragmentNode::RenderTag(_) | FragmentNode::HtmlTag(_) => true, + // A `
` is a rendered line break — line-owning, like a comment (the doc comment's + // second exclusion). Keyed on the name alone: `TagFacts::is_void` covers every void + // element, and the others render inline. + FragmentNode::Element(el) if el.name(self.source) == "br" => false, // An inline element/component flows; a block one owns its line. FragmentNode::Element(_) | FragmentNode::SpecialElement(_) => { !self.is_block_element_node(node) diff --git a/docs/conformance_prettier_svelte.md b/docs/conformance_prettier_svelte.md index 2b04ce558..76facdcd5 100644 --- a/docs/conformance_prettier_svelte.md +++ b/docs/conformance_prettier_svelte.md @@ -286,7 +286,7 @@ Note this is **orthogonal to whether the element lays out multiline at all**, wh ### What the rule does not reshape, and where convergence stops -Four things are **not** reshaped, because none is a mere spelling difference. A **comment** keeps its authored line (its position is authorship — folding one into a fill would relocate it across a semantic boundary, see [§Comment Position Philosophy](./conformance_prettier.md#comment-position-philosophy)); a **blank line** still breaks (a Tier-2 authoring signal independent of render); a **block sibling** still takes its own line (blocks merely partition a fragment into inline runs, each of which flows on its own); and a **control-flow block** (`{#if}` / `{#each}` / `{#key}` / `{#await}` / `{#snippet}`) keeps its own line too — for `{#snippet}` that is unconditional (it is a declaration and takes its own line, [see below](#svelte-inline-content-block-style)), so only the four rendering heads remain in question here. The reason for that last one is neither "a block's width is not fixed" (a breaking `{expr}` tag expands mid-run too — `{f(⏎…⏎)}text4` — so width separates nothing) nor a bare appeal to a fixture. It is that **a flowed block has no way to pay an overflow except by tearing itself open.** An inline element that cannot fit drops to its own line *whole*, tags intact — that is what `break_before_wide_flow` buys, and it is what makes flowing safe for elements. A **spaced** block follower has that escape too (the spaced half of `break_before_wide_flow` admits control-flow blocks — [§Svelte: Blocks, "Multiline block head after spaced text"](#svelte-blocks)), but a **glued** one still does not: a glued block detaches by its own layout, so its weld survives only in the source (measuring it as a welded unit is a two-pass hazard), and the only break available there is the block's own head↔body seam — the body node lands on its own line and the flowed sibling text welds to the tail (`{#key key}⏎text6⏎{/key}text7`). The visible cost is that identical constructs then render differently by horizontal accident — in a run of five blocks, the two that happen to straddle the width boundary expand while their siblings stay inline. So the exclusion is a **consequence of a missing mechanism, not a property of blocks**: admitting them to the flow is gated on the remaining glued half of that whole-unit drop, not on re-litigating this predicate. Measured against the fixture suite, admitting blocks as-is converges ~39 more `authoring_audit` sites — the yield is real, which is exactly why the bar is the layout, not the count. A breaking `{expr}` tag, by contrast, expands *inside its own expression* (the call's argument list) and leaves both of its outer adjacencies untouched, so it flows without this hazard — a settled choice rather than a rough edge. +Five things are **not** reshaped, because none is a mere spelling difference. A **comment** keeps its authored line (its position is authorship — folding one into a fill would relocate it across a semantic boundary, see [§Comment Position Philosophy](./conformance_prettier.md#comment-position-philosophy)); a **`
`** keeps its authored line too — it *is* a rendered line break, so the source newline beside it mirrors the render rather than spelling a space, which is the one licence the flow rule runs on; it is line-owning exactly as a comment is (it bounds the run without sterilizing it, and its space spelling `text
text` is never forced open), and prettier holds it as well, so this is agreement rather than divergence — [void_br_newline](../tests/fixtures/svelte/elements/void_br_newline/) pins every authoring and [inline_sibling_newline_flow](../tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/)'s `
` control carries the bounding-not-sterilizing half beside the comment's; a **blank line** still breaks (a Tier-2 authoring signal independent of render); a **block sibling** still takes its own line (blocks merely partition a fragment into inline runs, each of which flows on its own); and a **control-flow block** (`{#if}` / `{#each}` / `{#key}` / `{#await}` / `{#snippet}`) keeps its own line too — for `{#snippet}` that is unconditional (it is a declaration and takes its own line, [see below](#svelte-inline-content-block-style)), so only the four rendering heads remain in question here. The reason for that last one is neither "a block's width is not fixed" (a breaking `{expr}` tag expands mid-run too — `{f(⏎…⏎)}text4` — so width separates nothing) nor a bare appeal to a fixture. It is that **a flowed block has no way to pay an overflow except by tearing itself open.** An inline element that cannot fit drops to its own line *whole*, tags intact — that is what `break_before_wide_flow` buys, and it is what makes flowing safe for elements. A **spaced** block follower has that escape too (the spaced half of `break_before_wide_flow` admits control-flow blocks — [§Svelte: Blocks, "Multiline block head after spaced text"](#svelte-blocks)), but a **glued** one still does not: a glued block detaches by its own layout, so its weld survives only in the source (measuring it as a welded unit is a two-pass hazard), and the only break available there is the block's own head↔body seam — the body node lands on its own line and the flowed sibling text welds to the tail (`{#key key}⏎text6⏎{/key}text7`). The visible cost is that identical constructs then render differently by horizontal accident — in a run of five blocks, the two that happen to straddle the width boundary expand while their siblings stay inline. So the exclusion is a **consequence of a missing mechanism, not a property of blocks**: admitting them to the flow is gated on the remaining glued half of that whole-unit drop, not on re-litigating this predicate. Measured against the fixture suite, admitting blocks as-is converges ~39 more `authoring_audit` sites — the yield is real, which is exactly why the bar is the layout, not the count. A breaking `{expr}` tag, by contrast, expands *inside its own expression* (the call's argument list) and leaves both of its outer adjacencies untouched, so it flows without this hazard — a settled choice rather than a rough edge. **The comment exclusion is held on each SIDE independently, and it is where this section's convergence deliberately stops rather than a divergence from prettier.** "Keeps its authored line" is the symmetric reading, and it is the weaker one: the newline *after* a comment holds the following run off the comment's line exactly as the newline *before* it holds the comment off the preceding run's, so a one-sided authoring is a fixed point on that side alone — `text1 ⏎text2` and `text1⏎ text2` both stay, at any width, beside the both-sided form — and beside the form with a newline on neither side, which stays hugged, because the rule HOLDS an authored line rather than FORCING one around a comment (that fourth authoring is the pair's null control: it varies the same dimension, so without it an implementation that always broke both sides would satisfy the other three). Prettier holds all four too, so there is nothing to catalog against it here; the exclusion's whole cost is that these authorings do not converge with each other, which is the price [§Comment Position Philosophy](./conformance_prettier.md#comment-position-philosophy) is already paid for. ⚠️ **It is comment-specific, and the discriminating control has to hold the SITE fixed** — an element or a tag in the identical position flows (`text1 a⏎text2` collapses). Two *other* gates in this rule suppress flow for every sibling kind at once (the prose gate below, and the reflowable-fill suppression the paragraph after it, which closes this rule by making the element multiline for a reason it does not read), so an element control run in a shape either one already catches keeps its lines regardless of what sits there, and reads back as "the newline rule is not about comments" when it is. — [inline_separator_comment_newline](../tests/fixtures/svelte/elements/inline_separator_comment_newline/) pins all four comment authorings, and is deliberately **not** a divergence fixture: prettier holds each one too, so there is nothing for an `output_prettier` to claim. The element twins of the one-sided pair are [inline_sibling_newline_flow](../tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/)'s `prettier_variant_newline_after` / `prettier_variant_newline_before`, which converge on its input — that pair beside these four is the whole control. ⚠️ **The exclusion is scoped to the comment's OWN two boundaries: it BOUNDS the run, it does not STERILIZE one.** The runs a comment separates keep flowing on their own — `text1 a text2⏎⏎text3 b text4` converges from every isolated authoring of those spans, with only the comment's two newlines held. Nothing distinguishes that from the wider reading ("a run holding a comment keeps every line") unless a control puts a flowing run *beside* the comment and re-authors it: a control whose run is already hugged in every file is a fixed point under either rule and cannot separate them, which is why [inline_sibling_newline_flow](../tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/)'s comment-boundary control is re-authored in all three `prettier_variant_*` files rather than held. The same is true of every other run-bounding sibling (that fixture's block-sibling control carries the parallel pin), so the property belongs to run boundaries in general and not to comments — what is comment-specific is only the *holding*. The practical consequence is that a comment tsv has broken onto its own line for **width** ([fill_break_before_comment_spaced_long](../tests/fixtures/svelte/elements/fill_break_before_comment_spaced_long_prettier_divergence/)) reaches a second fixed point when the run after it was authored on the next line — the same document, differing only in whether that run shares the comment's line. diff --git a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/expected.json b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/expected.json index 16ce96f58..cbb4e0315 100644 --- a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/expected.json +++ b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/expected.json @@ -2,7 +2,7 @@ "css": null, "js": [], "start": 0, - "end": 2627, + "end": 2996, "type": "Root", "fragment": { "type": "Fragment", @@ -10,31 +10,31 @@ { "type": "Comment", "start": 0, - "end": 1351, - "data": "\n\tAn inline sibling isolated by authored newlines flows back onto the content line. Svelte 5\n\tcollapses inter-sibling whitespace to one space, so a newline and a space between two siblings\n\trender identically and the newline carries no signal the fill must honor. What an authored\n\tnewline does still decide is the element's own layout: a newline anywhere in the content keeps\n\tthe element multiline (want air, author multiline), so these converge on the multiline form\n\trather than collapsing onto one line. Prettier holds a distinct stable form for each authoring.\n\tCovers an inline element, a component, and all three tag kinds — an expression tag, a render\n\ttag and an `{@html}` tag, which the flow predicate answers alike. The controls pin\n\twhat does not flow: a control-flow block, whose width is not fixed (packing a run of them\n\toverflows the line, and the overflow is paid by expanding their bodies); the fully hugged\n\tauthoring, which stays hugged; a comment, which keeps its authored line; a blank line, which\n\tstill breaks; and a block sibling, which still takes its own line. Two of those controls also\n\tcarry an inline run beside the bounding sibling, re-authored in every variant, so \"the run it\n\tbounds still flows\" is DEMONSTRATED rather than asserted — a sibling that owns its own line\n\tends a run, it does not sterilize one.\n" + "end": 1422, + "data": "\n\tAn inline sibling isolated by authored newlines flows back onto the content line. Svelte 5\n\tcollapses inter-sibling whitespace to one space, so a newline and a space between two siblings\n\trender identically and the newline carries no signal the fill must honor. What an authored\n\tnewline does still decide is the element's own layout: a newline anywhere in the content keeps\n\tthe element multiline (want air, author multiline), so these converge on the multiline form\n\trather than collapsing onto one line. Prettier holds a distinct stable form for each authoring.\n\tCovers an inline element, a component, and all three tag kinds — an expression tag, a render\n\ttag and an `{@html}` tag, which the flow predicate answers alike. The controls pin\n\twhat does not flow: a control-flow block, whose width is not fixed (packing a run of them\n\toverflows the line, and the overflow is paid by expanding their bodies); the fully hugged\n\tauthoring, which stays hugged; a comment, which keeps its authored line; a blank line, which\n\tstill breaks; a block sibling, which still takes its own line; and a `
`, a rendered line\n\tbreak whose newline mirrors the render. Three of those controls also carry an inline run\n\tbeside the bounding sibling, re-authored in every variant, so \"the run it bounds still flows\"\n\tis DEMONSTRATED rather than asserted — a sibling that owns its own line ends a run, it does\n\tnot sterilize one.\n" }, { "type": "Text", - "start": 1351, - "end": 1352, + "start": 1422, + "end": 1423, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1352, - "end": 1400, + "start": 1423, + "end": 1471, "name": "p", "name_loc": { "start": { - "line": 18, + "line": 19, "column": 1, - "character": 1353 + "character": 1424 }, "end": { - "line": 18, + "line": 19, "column": 2, - "character": 1354 + "character": 1425 } }, "attributes": [], @@ -43,26 +43,26 @@ "nodes": [ { "type": "Text", - "start": 1355, - "end": 1363, + "start": 1426, + "end": 1434, "raw": "\n\ttext1 ", "data": "\n\ttext1 " }, { "type": "RegularElement", - "start": 1363, - "end": 1383, + "start": 1434, + "end": 1454, "name": "span", "name_loc": { "start": { - "line": 19, + "line": 20, "column": 8, - "character": 1364 + "character": 1435 }, "end": { - "line": 19, + "line": 20, "column": 12, - "character": 1368 + "character": 1439 } }, "attributes": [], @@ -71,8 +71,8 @@ "nodes": [ { "type": "Text", - "start": 1369, - "end": 1376, + "start": 1440, + "end": 1447, "raw": "inline1", "data": "inline1" } @@ -81,8 +81,8 @@ }, { "type": "Text", - "start": 1383, - "end": 1396, + "start": 1454, + "end": 1467, "raw": " text2 text3\n", "data": " text2 text3\n" } @@ -91,26 +91,26 @@ }, { "type": "Text", - "start": 1400, - "end": 1401, + "start": 1471, + "end": 1472, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1401, - "end": 1450, + "start": 1472, + "end": 1521, "name": "p", "name_loc": { "start": { - "line": 21, + "line": 22, "column": 1, - "character": 1402 + "character": 1473 }, "end": { - "line": 21, + "line": 22, "column": 2, - "character": 1403 + "character": 1474 } }, "attributes": [], @@ -119,50 +119,50 @@ "nodes": [ { "type": "Text", - "start": 1404, - "end": 1412, + "start": 1475, + "end": 1483, "raw": "\n\ttext1 ", "data": "\n\ttext1 " }, { "type": "Component", - "start": 1412, - "end": 1433, + "start": 1483, + "end": 1504, "name": "Comp", "name_loc": { "start": { - "line": 22, + "line": 23, "column": 8, - "character": 1413 + "character": 1484 }, "end": { - "line": 22, + "line": 23, "column": 12, - "character": 1417 + "character": 1488 } }, "attributes": [ { "type": "Attribute", - "start": 1418, - "end": 1430, + "start": 1489, + "end": 1501, "name": "prop", "name_loc": { "start": { - "line": 22, + "line": 23, "column": 13, - "character": 1418 + "character": 1489 }, "end": { - "line": 22, + "line": 23, "column": 17, - "character": 1422 + "character": 1493 } }, "value": [ { - "start": 1424, - "end": 1429, + "start": 1495, + "end": 1500, "type": "Text", "raw": "value", "data": "value" @@ -177,8 +177,8 @@ }, { "type": "Text", - "start": 1433, - "end": 1446, + "start": 1504, + "end": 1517, "raw": " text2 text3\n", "data": " text2 text3\n" } @@ -187,26 +187,26 @@ }, { "type": "Text", - "start": 1450, - "end": 1451, + "start": 1521, + "end": 1522, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1451, - "end": 1485, + "start": 1522, + "end": 1556, "name": "p", "name_loc": { "start": { - "line": 24, + "line": 25, "column": 1, - "character": 1452 + "character": 1523 }, "end": { - "line": 24, + "line": 25, "column": 2, - "character": 1453 + "character": 1524 } }, "attributes": [], @@ -215,26 +215,26 @@ "nodes": [ { "type": "Text", - "start": 1454, - "end": 1462, + "start": 1525, + "end": 1533, "raw": "\n\ttext1 ", "data": "\n\ttext1 " }, { "type": "ExpressionTag", - "start": 1462, - "end": 1468, + "start": 1533, + "end": 1539, "expression": { "type": "Identifier", - "start": 1463, - "end": 1467, + "start": 1534, + "end": 1538, "loc": { "start": { - "line": 25, + "line": 26, "column": 8 }, "end": { - "line": 25, + "line": 26, "column": 12 } }, @@ -243,8 +243,8 @@ }, { "type": "Text", - "start": 1468, - "end": 1481, + "start": 1539, + "end": 1552, "raw": " text2 text3\n", "data": " text2 text3\n" } @@ -253,26 +253,26 @@ }, { "type": "Text", - "start": 1485, - "end": 1486, + "start": 1556, + "end": 1557, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1486, - "end": 1528, + "start": 1557, + "end": 1599, "name": "p", "name_loc": { "start": { - "line": 27, + "line": 28, "column": 1, - "character": 1487 + "character": 1558 }, "end": { - "line": 27, + "line": 28, "column": 2, - "character": 1488 + "character": 1559 } }, "attributes": [], @@ -281,40 +281,40 @@ "nodes": [ { "type": "Text", - "start": 1489, - "end": 1497, + "start": 1560, + "end": 1568, "raw": "\n\ttext1 ", "data": "\n\ttext1 " }, { "type": "RenderTag", - "start": 1497, - "end": 1511, + "start": 1568, + "end": 1582, "expression": { "type": "CallExpression", - "start": 1506, - "end": 1510, + "start": 1577, + "end": 1581, "loc": { "start": { - "line": 28, + "line": 29, "column": 16 }, "end": { - "line": 28, + "line": 29, "column": 20 } }, "callee": { "type": "Identifier", - "start": 1506, - "end": 1508, + "start": 1577, + "end": 1579, "loc": { "start": { - "line": 28, + "line": 29, "column": 16 }, "end": { - "line": 28, + "line": 29, "column": 18 } }, @@ -326,8 +326,8 @@ }, { "type": "Text", - "start": 1511, - "end": 1524, + "start": 1582, + "end": 1595, "raw": " text2 text3\n", "data": " text2 text3\n" } @@ -336,26 +336,26 @@ }, { "type": "Text", - "start": 1528, - "end": 1529, + "start": 1599, + "end": 1600, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1529, - "end": 1569, + "start": 1600, + "end": 1640, "name": "p", "name_loc": { "start": { - "line": 30, + "line": 31, "column": 1, - "character": 1530 + "character": 1601 }, "end": { - "line": 30, + "line": 31, "column": 2, - "character": 1531 + "character": 1602 } }, "attributes": [], @@ -364,26 +364,26 @@ "nodes": [ { "type": "Text", - "start": 1532, - "end": 1540, + "start": 1603, + "end": 1611, "raw": "\n\ttext1 ", "data": "\n\ttext1 " }, { "type": "HtmlTag", - "start": 1540, - "end": 1552, + "start": 1611, + "end": 1623, "expression": { "type": "Identifier", - "start": 1547, - "end": 1551, + "start": 1618, + "end": 1622, "loc": { "start": { - "line": 31, + "line": 32, "column": 14 }, "end": { - "line": 31, + "line": 32, "column": 18 } }, @@ -392,8 +392,8 @@ }, { "type": "Text", - "start": 1552, - "end": 1565, + "start": 1623, + "end": 1636, "raw": " text2 text3\n", "data": " text2 text3\n" } @@ -402,39 +402,39 @@ }, { "type": "Text", - "start": 1569, - "end": 1571, + "start": 1640, + "end": 1642, "raw": "\n\n", "data": "\n\n" }, { "type": "Comment", - "start": 1571, - "end": 1741, + "start": 1642, + "end": 1812, "data": " control: a control-flow block keeps its authored line — packing a run of them onto one\n line overflows it, and the overflow is paid by expanding their bodies " }, { "type": "Text", - "start": 1741, - "end": 1742, + "start": 1812, + "end": 1813, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1742, - "end": 1794, + "start": 1813, + "end": 1865, "name": "p", "name_loc": { "start": { - "line": 36, + "line": 37, "column": 1, - "character": 1743 + "character": 1814 }, "end": { - "line": 36, + "line": 37, "column": 2, - "character": 1744 + "character": 1815 } }, "attributes": [], @@ -443,27 +443,27 @@ "nodes": [ { "type": "Text", - "start": 1745, - "end": 1754, + "start": 1816, + "end": 1825, "raw": "\n\ttext1\n\t", "data": "\n\ttext1\n\t" }, { "type": "IfBlock", "elseif": false, - "start": 1754, - "end": 1776, + "start": 1825, + "end": 1847, "test": { "type": "Identifier", - "start": 1759, - "end": 1763, + "start": 1830, + "end": 1834, "loc": { "start": { - "line": 38, + "line": 39, "column": 6 }, "end": { - "line": 38, + "line": 39, "column": 10 } }, @@ -474,8 +474,8 @@ "nodes": [ { "type": "Text", - "start": 1764, - "end": 1771, + "start": 1835, + "end": 1842, "raw": "inline1", "data": "inline1" } @@ -485,8 +485,8 @@ }, { "type": "Text", - "start": 1776, - "end": 1790, + "start": 1847, + "end": 1861, "raw": "\n\ttext2 text3\n", "data": "\n\ttext2 text3\n" } @@ -495,39 +495,39 @@ }, { "type": "Text", - "start": 1794, - "end": 1796, + "start": 1865, + "end": 1867, "raw": "\n\n", "data": "\n\n" }, { "type": "Comment", - "start": 1796, - "end": 1853, + "start": 1867, + "end": 1924, "data": " control: the fully hugged authoring stays hugged " }, { "type": "Text", - "start": 1853, - "end": 1854, + "start": 1924, + "end": 1925, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1854, - "end": 1899, + "start": 1925, + "end": 1970, "name": "p", "name_loc": { "start": { - "line": 43, + "line": 44, "column": 1, - "character": 1855 + "character": 1926 }, "end": { - "line": 43, + "line": 44, "column": 2, - "character": 1856 + "character": 1927 } }, "attributes": [], @@ -536,26 +536,26 @@ "nodes": [ { "type": "Text", - "start": 1857, - "end": 1863, + "start": 1928, + "end": 1934, "raw": "text1 ", "data": "text1 " }, { "type": "RegularElement", - "start": 1863, - "end": 1883, + "start": 1934, + "end": 1954, "name": "span", "name_loc": { "start": { - "line": 43, + "line": 44, "column": 10, - "character": 1864 + "character": 1935 }, "end": { - "line": 43, + "line": 44, "column": 14, - "character": 1868 + "character": 1939 } }, "attributes": [], @@ -564,8 +564,8 @@ "nodes": [ { "type": "Text", - "start": 1869, - "end": 1876, + "start": 1940, + "end": 1947, "raw": "inline1", "data": "inline1" } @@ -574,8 +574,8 @@ }, { "type": "Text", - "start": 1883, - "end": 1895, + "start": 1954, + "end": 1966, "raw": " text2 text3", "data": " text2 text3" } @@ -584,39 +584,39 @@ }, { "type": "Text", - "start": 1899, - "end": 1901, + "start": 1970, + "end": 1972, "raw": "\n\n", "data": "\n\n" }, { "type": "Comment", - "start": 1901, - "end": 1952, + "start": 1972, + "end": 2023, "data": " control: a comment keeps its authored line " }, { "type": "Text", - "start": 1952, - "end": 1953, + "start": 2023, + "end": 2024, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 1953, - "end": 1987, + "start": 2024, + "end": 2058, "name": "p", "name_loc": { "start": { - "line": 46, + "line": 47, "column": 1, - "character": 1954 + "character": 2025 }, "end": { - "line": 46, + "line": 47, "column": 2, - "character": 1955 + "character": 2026 } }, "attributes": [], @@ -625,21 +625,21 @@ "nodes": [ { "type": "Text", - "start": 1956, - "end": 1965, + "start": 2027, + "end": 2036, "raw": "\n\ttext1\n\t", "data": "\n\ttext1\n\t" }, { "type": "Comment", - "start": 1965, - "end": 1975, + "start": 2036, + "end": 2046, "data": " c " }, { "type": "Text", - "start": 1975, - "end": 1983, + "start": 2046, + "end": 2054, "raw": "\n\ttext2\n", "data": "\n\ttext2\n" } @@ -648,39 +648,39 @@ }, { "type": "Text", - "start": 1987, - "end": 1989, + "start": 2058, + "end": 2060, "raw": "\n\n", "data": "\n\n" }, { "type": "Comment", - "start": 1989, - "end": 2274, + "start": 2060, + "end": 2345, "data": " control: a comment BOUNDS the run without sterilizing it — it keeps its own line, and the\n inline runs on BOTH sides of it still flow. Without this the comment control above is equally\n satisfied by \"a run holding a comment keeps every line\", which is a different rule " }, { "type": "Text", - "start": 2274, - "end": 2275, + "start": 2345, + "end": 2346, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 2275, - "end": 2363, + "start": 2346, + "end": 2434, "name": "p", "name_loc": { "start": { - "line": 55, + "line": 56, "column": 1, - "character": 2276 + "character": 2347 }, "end": { - "line": 55, + "line": 56, "column": 2, - "character": 2277 + "character": 2348 } }, "attributes": [], @@ -689,26 +689,26 @@ "nodes": [ { "type": "Text", - "start": 2278, - "end": 2286, + "start": 2349, + "end": 2357, "raw": "\n\ttext1 ", "data": "\n\ttext1 " }, { "type": "RegularElement", - "start": 2286, - "end": 2306, + "start": 2357, + "end": 2377, "name": "span", "name_loc": { "start": { - "line": 56, + "line": 57, "column": 8, - "character": 2287 + "character": 2358 }, "end": { - "line": 56, + "line": 57, "column": 12, - "character": 2291 + "character": 2362 } }, "attributes": [], @@ -717,8 +717,8 @@ "nodes": [ { "type": "Text", - "start": 2292, - "end": 2299, + "start": 2363, + "end": 2370, "raw": "inline1", "data": "inline1" } @@ -727,39 +727,196 @@ }, { "type": "Text", - "start": 2306, - "end": 2314, + "start": 2377, + "end": 2385, "raw": " text2\n\t", "data": " text2\n\t" }, { "type": "Comment", - "start": 2314, - "end": 2324, + "start": 2385, + "end": 2395, "data": " c " }, { "type": "Text", - "start": 2324, - "end": 2332, + "start": 2395, + "end": 2403, + "raw": "\n\ttext3 ", + "data": "\n\ttext3 " + }, + { + "type": "RegularElement", + "start": 2403, + "end": 2423, + "name": "span", + "name_loc": { + "start": { + "line": 59, + "column": 8, + "character": 2404 + }, + "end": { + "line": 59, + "column": 12, + "character": 2408 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 2409, + "end": 2416, + "raw": "inline2", + "data": "inline2" + } + ] + } + }, + { + "type": "Text", + "start": 2423, + "end": 2430, + "raw": " text4\n", + "data": " text4\n" + } + ] + } + }, + { + "type": "Text", + "start": 2434, + "end": 2436, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 2436, + "end": 2647, + "data": " control: a `
` bounds the run exactly as a comment does — its newline is a rendered\n line break, not a spelling of a space, so it keeps its own line while the runs on both\n sides still flow " + }, + { + "type": "Text", + "start": 2647, + "end": 2648, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 2648, + "end": 2732, + "name": "p", + "name_loc": { + "start": { + "line": 65, + "column": 1, + "character": 2649 + }, + "end": { + "line": 65, + "column": 2, + "character": 2650 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 2651, + "end": 2659, + "raw": "\n\ttext1 ", + "data": "\n\ttext1 " + }, + { + "type": "RegularElement", + "start": 2659, + "end": 2679, + "name": "span", + "name_loc": { + "start": { + "line": 66, + "column": 8, + "character": 2660 + }, + "end": { + "line": 66, + "column": 12, + "character": 2664 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 2665, + "end": 2672, + "raw": "inline1", + "data": "inline1" + } + ] + } + }, + { + "type": "Text", + "start": 2679, + "end": 2687, + "raw": " text2\n\t", + "data": " text2\n\t" + }, + { + "type": "RegularElement", + "start": 2687, + "end": 2693, + "name": "br", + "name_loc": { + "start": { + "line": 67, + "column": 2, + "character": 2688 + }, + "end": { + "line": 67, + "column": 4, + "character": 2690 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 2693, + "end": 2701, "raw": "\n\ttext3 ", "data": "\n\ttext3 " }, { "type": "RegularElement", - "start": 2332, - "end": 2352, + "start": 2701, + "end": 2721, "name": "span", "name_loc": { "start": { - "line": 58, + "line": 68, "column": 8, - "character": 2333 + "character": 2702 }, "end": { - "line": 58, + "line": 68, "column": 12, - "character": 2337 + "character": 2706 } }, "attributes": [], @@ -768,8 +925,8 @@ "nodes": [ { "type": "Text", - "start": 2338, - "end": 2345, + "start": 2707, + "end": 2714, "raw": "inline2", "data": "inline2" } @@ -778,8 +935,8 @@ }, { "type": "Text", - "start": 2352, - "end": 2359, + "start": 2721, + "end": 2728, "raw": " text4\n", "data": " text4\n" } @@ -788,39 +945,39 @@ }, { "type": "Text", - "start": 2363, - "end": 2365, + "start": 2732, + "end": 2734, "raw": "\n\n", "data": "\n\n" }, { "type": "Comment", - "start": 2365, - "end": 2408, + "start": 2734, + "end": 2777, "data": " control: a blank line still breaks " }, { "type": "Text", - "start": 2408, - "end": 2409, + "start": 2777, + "end": 2778, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 2409, - "end": 2455, + "start": 2778, + "end": 2824, "name": "p", "name_loc": { "start": { - "line": 62, + "line": 72, "column": 1, - "character": 2410 + "character": 2779 }, "end": { - "line": 62, + "line": 72, "column": 2, - "character": 2411 + "character": 2780 } }, "attributes": [], @@ -829,26 +986,26 @@ "nodes": [ { "type": "Text", - "start": 2412, - "end": 2422, + "start": 2781, + "end": 2791, "raw": "\n\ttext1\n\n\t", "data": "\n\ttext1\n\n\t" }, { "type": "RegularElement", - "start": 2422, - "end": 2442, + "start": 2791, + "end": 2811, "name": "span", "name_loc": { "start": { - "line": 65, + "line": 75, "column": 2, - "character": 2423 + "character": 2792 }, "end": { - "line": 65, + "line": 75, "column": 6, - "character": 2427 + "character": 2796 } }, "attributes": [], @@ -857,8 +1014,8 @@ "nodes": [ { "type": "Text", - "start": 2428, - "end": 2435, + "start": 2797, + "end": 2804, "raw": "inline1", "data": "inline1" } @@ -867,8 +1024,8 @@ }, { "type": "Text", - "start": 2442, - "end": 2451, + "start": 2811, + "end": 2820, "raw": "\n\n\ttext2\n", "data": "\n\n\ttext2\n" } @@ -877,39 +1034,39 @@ }, { "type": "Text", - "start": 2455, - "end": 2457, + "start": 2824, + "end": 2826, "raw": "\n\n", "data": "\n\n" }, { "type": "Comment", - "start": 2457, - "end": 2547, + "start": 2826, + "end": 2916, "data": " control: a block sibling takes its own line; the inline run before it still flows " }, { "type": "Text", - "start": 2547, - "end": 2548, + "start": 2916, + "end": 2917, "raw": "\n", "data": "\n" }, { "type": "RegularElement", - "start": 2548, - "end": 2626, + "start": 2917, + "end": 2995, "name": "div", "name_loc": { "start": { - "line": 71, + "line": 81, "column": 1, - "character": 2549 + "character": 2918 }, "end": { - "line": 71, + "line": 81, "column": 4, - "character": 2552 + "character": 2921 } }, "attributes": [], @@ -918,26 +1075,26 @@ "nodes": [ { "type": "Text", - "start": 2553, - "end": 2561, + "start": 2922, + "end": 2930, "raw": "\n\ttext1 ", "data": "\n\ttext1 " }, { "type": "RegularElement", - "start": 2561, - "end": 2581, + "start": 2930, + "end": 2950, "name": "span", "name_loc": { "start": { - "line": 72, + "line": 82, "column": 8, - "character": 2562 + "character": 2931 }, "end": { - "line": 72, + "line": 82, "column": 12, - "character": 2566 + "character": 2935 } }, "attributes": [], @@ -946,8 +1103,8 @@ "nodes": [ { "type": "Text", - "start": 2567, - "end": 2574, + "start": 2936, + "end": 2943, "raw": "inline1", "data": "inline1" } @@ -956,26 +1113,26 @@ }, { "type": "Text", - "start": 2581, - "end": 2589, + "start": 2950, + "end": 2958, "raw": " text2\n\t", "data": " text2\n\t" }, { "type": "RegularElement", - "start": 2589, - "end": 2606, + "start": 2958, + "end": 2975, "name": "div", "name_loc": { "start": { - "line": 73, + "line": 83, "column": 2, - "character": 2590 + "character": 2959 }, "end": { - "line": 73, + "line": 83, "column": 5, - "character": 2593 + "character": 2962 } }, "attributes": [], @@ -984,8 +1141,8 @@ "nodes": [ { "type": "Text", - "start": 2594, - "end": 2600, + "start": 2963, + "end": 2969, "raw": "block1", "data": "block1" } @@ -994,8 +1151,8 @@ }, { "type": "Text", - "start": 2606, - "end": 2620, + "start": 2975, + "end": 2989, "raw": "\n\ttext3 text4\n", "data": "\n\ttext3 text4\n" } diff --git a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/input.svelte b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/input.svelte index 11f916ec4..41339d6bb 100644 --- a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/input.svelte +++ b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/input.svelte @@ -10,10 +10,11 @@ what does not flow: a control-flow block, whose width is not fixed (packing a run of them overflows the line, and the overflow is paid by expanding their bodies); the fully hugged authoring, which stays hugged; a comment, which keeps its authored line; a blank line, which - still breaks; and a block sibling, which still takes its own line. Two of those controls also - carry an inline run beside the bounding sibling, re-authored in every variant, so "the run it - bounds still flows" is DEMONSTRATED rather than asserted — a sibling that owns its own line - ends a run, it does not sterilize one. + still breaks; a block sibling, which still takes its own line; and a `
`, a rendered line + break whose newline mirrors the render. Three of those controls also carry an inline run + beside the bounding sibling, re-authored in every variant, so "the run it bounds still flows" + is DEMONSTRATED rather than asserted — a sibling that owns its own line ends a run, it does + not sterilize one. -->

text1 inline1 text2 text3 @@ -58,6 +59,15 @@ text3 inline2 text4

+ +

+ text1 inline1 text2 +
+ text3 inline2 text4 +

+

text1 diff --git a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_after.svelte b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_after.svelte index bdb0fd51d..d004753eb 100644 --- a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_after.svelte +++ b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_after.svelte @@ -10,10 +10,11 @@ what does not flow: a control-flow block, whose width is not fixed (packing a run of them overflows the line, and the overflow is paid by expanding their bodies); the fully hugged authoring, which stays hugged; a comment, which keeps its authored line; a blank line, which - still breaks; and a block sibling, which still takes its own line. Two of those controls also - carry an inline run beside the bounding sibling, re-authored in every variant, so "the run it - bounds still flows" is DEMONSTRATED rather than asserted — a sibling that owns its own line - ends a run, it does not sterilize one. + still breaks; a block sibling, which still takes its own line; and a `
`, a rendered line + break whose newline mirrors the render. Three of those controls also carry an inline run + beside the bounding sibling, re-authored in every variant, so "the run it bounds still flows" + is DEMONSTRATED rather than asserted — a sibling that owns its own line ends a run, it does + not sterilize one. -->

text1 inline1 @@ -65,6 +66,17 @@ text4

+ +

+ text1 inline1 + text2 +
+ text3 inline2 + text4 +

+

text1 diff --git a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_before.svelte b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_before.svelte index 519066343..7de48260d 100644 --- a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_before.svelte +++ b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_before.svelte @@ -10,10 +10,11 @@ what does not flow: a control-flow block, whose width is not fixed (packing a run of them overflows the line, and the overflow is paid by expanding their bodies); the fully hugged authoring, which stays hugged; a comment, which keeps its authored line; a blank line, which - still breaks; and a block sibling, which still takes its own line. Two of those controls also - carry an inline run beside the bounding sibling, re-authored in every variant, so "the run it - bounds still flows" is DEMONSTRATED rather than asserted — a sibling that owns its own line - ends a run, it does not sterilize one. + still breaks; a block sibling, which still takes its own line; and a `
`, a rendered line + break whose newline mirrors the render. Three of those controls also carry an inline run + beside the bounding sibling, re-authored in every variant, so "the run it bounds still flows" + is DEMONSTRATED rather than asserted — a sibling that owns its own line ends a run, it does + not sterilize one. -->

text1 @@ -65,6 +66,17 @@ inline2 text4

+ +

+ text1 + inline1 text2 +
+ text3 + inline2 text4 +

+

text1 diff --git a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_both.svelte b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_both.svelte index dfaa1512c..6c64452be 100644 --- a/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_both.svelte +++ b/tests/fixtures/svelte/elements/inline_sibling_newline_flow_prettier_divergence/prettier_variant_newline_both.svelte @@ -10,10 +10,11 @@ what does not flow: a control-flow block, whose width is not fixed (packing a run of them overflows the line, and the overflow is paid by expanding their bodies); the fully hugged authoring, which stays hugged; a comment, which keeps its authored line; a blank line, which - still breaks; and a block sibling, which still takes its own line. Two of those controls also - carry an inline run beside the bounding sibling, re-authored in every variant, so "the run it - bounds still flows" is DEMONSTRATED rather than asserted — a sibling that owns its own line - ends a run, it does not sterilize one. + still breaks; a block sibling, which still takes its own line; and a `
`, a rendered line + break whose newline mirrors the render. Three of those controls also carry an inline run + beside the bounding sibling, re-authored in every variant, so "the run it bounds still flows" + is DEMONSTRATED rather than asserted — a sibling that owns its own line ends a run, it does + not sterilize one. -->

text1 @@ -72,6 +73,19 @@ text4

+ +

+ text1 + inline1 + text2 +
+ text3 + inline2 + text4 +

+

text1 diff --git a/tests/fixtures/svelte/elements/void_br_newline/expected.json b/tests/fixtures/svelte/elements/void_br_newline/expected.json new file mode 100644 index 000000000..fa2679899 --- /dev/null +++ b/tests/fixtures/svelte/elements/void_br_newline/expected.json @@ -0,0 +1,968 @@ +{ + "css": null, + "js": [], + "start": 0, + "end": 1295, + "type": "Root", + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Comment", + "start": 0, + "end": 437, + "data": "\n\tA `
` is a rendered line break, so a source newline beside it mirrors the render: it is\n\tnot a spelling of a space, and the sibling-newline flow rule holds it. Like a comment, the\n\t`
` owns its line — it BOUNDS a run without sterilizing it (the runs on either side are\n\tordinary fills). Both formatters hold every authoring below, and a `
` never FORCES a\n\tbreak: the space and hugged spellings stay as authored.\n" + }, + { + "type": "Text", + "start": 437, + "end": 439, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 439, + "end": 469, + "data": " newline on both sides " + }, + { + "type": "Text", + "start": 469, + "end": 470, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 470, + "end": 500, + "name": "p", + "name_loc": { + "start": { + "line": 10, + "column": 1, + "character": 471 + }, + "end": { + "line": 10, + "column": 2, + "character": 472 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 473, + "end": 482, + "raw": "\n\ttext1\n\t", + "data": "\n\ttext1\n\t" + }, + { + "type": "RegularElement", + "start": 482, + "end": 488, + "name": "br", + "name_loc": { + "start": { + "line": 12, + "column": 2, + "character": 483 + }, + "end": { + "line": 12, + "column": 4, + "character": 485 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 488, + "end": 496, + "raw": "\n\ttext2\n", + "data": "\n\ttext2\n" + } + ] + } + }, + { + "type": "Text", + "start": 500, + "end": 502, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 502, + "end": 564, + "data": " glued before, newline after — the line-per-line shape " + }, + { + "type": "Text", + "start": 564, + "end": 565, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 565, + "end": 624, + "name": "p", + "name_loc": { + "start": { + "line": 17, + "column": 1, + "character": 566 + }, + "end": { + "line": 17, + "column": 2, + "character": 567 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 568, + "end": 581, + "raw": "\n\ttext1 text2", + "data": "\n\ttext1 text2" + }, + { + "type": "RegularElement", + "start": 581, + "end": 587, + "name": "br", + "name_loc": { + "start": { + "line": 18, + "column": 13, + "character": 582 + }, + "end": { + "line": 18, + "column": 15, + "character": 584 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 587, + "end": 600, + "raw": "\n\ttext3 text4", + "data": "\n\ttext3 text4" + }, + { + "type": "RegularElement", + "start": 600, + "end": 606, + "name": "br", + "name_loc": { + "start": { + "line": 19, + "column": 13, + "character": 601 + }, + "end": { + "line": 19, + "column": 15, + "character": 603 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 606, + "end": 620, + "raw": "\n\ttext5 text6\n", + "data": "\n\ttext5 text6\n" + } + ] + } + }, + { + "type": "Text", + "start": 624, + "end": 626, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 626, + "end": 662, + "data": " space before, newline after " + }, + { + "type": "Text", + "start": 662, + "end": 663, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 663, + "end": 698, + "name": "p", + "name_loc": { + "start": { + "line": 24, + "column": 1, + "character": 664 + }, + "end": { + "line": 24, + "column": 2, + "character": 665 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 666, + "end": 680, + "raw": "\n\ttext1 text2 ", + "data": "\n\ttext1 text2 " + }, + { + "type": "RegularElement", + "start": 680, + "end": 686, + "name": "br", + "name_loc": { + "start": { + "line": 25, + "column": 14, + "character": 681 + }, + "end": { + "line": 25, + "column": 16, + "character": 683 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 686, + "end": 694, + "raw": "\n\ttext3\n", + "data": "\n\ttext3\n" + } + ] + } + }, + { + "type": "Text", + "start": 698, + "end": 700, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 700, + "end": 788, + "data": " control: the space spelling stays as authored — a `
` never forces a break " + }, + { + "type": "Text", + "start": 788, + "end": 789, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 789, + "end": 817, + "name": "p", + "name_loc": { + "start": { + "line": 30, + "column": 1, + "character": 790 + }, + "end": { + "line": 30, + "column": 2, + "character": 791 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 792, + "end": 800, + "raw": "\n\ttext1 ", + "data": "\n\ttext1 " + }, + { + "type": "RegularElement", + "start": 800, + "end": 806, + "name": "br", + "name_loc": { + "start": { + "line": 31, + "column": 8, + "character": 801 + }, + "end": { + "line": 31, + "column": 10, + "character": 803 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 806, + "end": 813, + "raw": " text2\n", + "data": " text2\n" + } + ] + } + }, + { + "type": "Text", + "start": 817, + "end": 818, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 818, + "end": 843, + "name": "p", + "name_loc": { + "start": { + "line": 33, + "column": 1, + "character": 819 + }, + "end": { + "line": 33, + "column": 2, + "character": 820 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 821, + "end": 827, + "raw": "text1 ", + "data": "text1 " + }, + { + "type": "RegularElement", + "start": 827, + "end": 833, + "name": "br", + "name_loc": { + "start": { + "line": 33, + "column": 10, + "character": 828 + }, + "end": { + "line": 33, + "column": 12, + "character": 830 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 833, + "end": 839, + "raw": " text2", + "data": " text2" + } + ] + } + }, + { + "type": "Text", + "start": 843, + "end": 845, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 845, + "end": 958, + "data": " a `
` before an inline element and before a tag: the newline holds, and the run after\n it flows " + }, + { + "type": "Text", + "start": 958, + "end": 959, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 959, + "end": 1032, + "name": "p", + "name_loc": { + "start": { + "line": 37, + "column": 1, + "character": 960 + }, + "end": { + "line": 37, + "column": 2, + "character": 961 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 962, + "end": 971, + "raw": "\n\ttext1\n\t", + "data": "\n\ttext1\n\t" + }, + { + "type": "RegularElement", + "start": 971, + "end": 977, + "name": "br", + "name_loc": { + "start": { + "line": 39, + "column": 2, + "character": 972 + }, + "end": { + "line": 39, + "column": 4, + "character": 974 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 977, + "end": 979, + "raw": "\n\t", + "data": "\n\t" + }, + { + "type": "RegularElement", + "start": 979, + "end": 999, + "name": "span", + "name_loc": { + "start": { + "line": 40, + "column": 2, + "character": 980 + }, + "end": { + "line": 40, + "column": 6, + "character": 984 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 985, + "end": 992, + "raw": "inline1", + "data": "inline1" + } + ] + } + }, + { + "type": "Text", + "start": 999, + "end": 1007, + "raw": " text2\n\t", + "data": " text2\n\t" + }, + { + "type": "RegularElement", + "start": 1007, + "end": 1013, + "name": "br", + "name_loc": { + "start": { + "line": 41, + "column": 2, + "character": 1008 + }, + "end": { + "line": 41, + "column": 4, + "character": 1010 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 1013, + "end": 1015, + "raw": "\n\t", + "data": "\n\t" + }, + { + "type": "ExpressionTag", + "start": 1015, + "end": 1021, + "expression": { + "type": "Identifier", + "start": 1016, + "end": 1020, + "loc": { + "start": { + "line": 42, + "column": 2 + }, + "end": { + "line": 42, + "column": 6 + } + }, + "name": "expr" + } + }, + { + "type": "Text", + "start": 1021, + "end": 1028, + "raw": " text3\n", + "data": " text3\n" + } + ] + } + }, + { + "type": "Text", + "start": 1032, + "end": 1034, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 1034, + "end": 1077, + "data": " two in a row, each on its own line " + }, + { + "type": "Text", + "start": 1077, + "end": 1078, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 1078, + "end": 1116, + "name": "p", + "name_loc": { + "start": { + "line": 46, + "column": 1, + "character": 1079 + }, + "end": { + "line": 46, + "column": 2, + "character": 1080 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 1081, + "end": 1090, + "raw": "\n\ttext1\n\t", + "data": "\n\ttext1\n\t" + }, + { + "type": "RegularElement", + "start": 1090, + "end": 1096, + "name": "br", + "name_loc": { + "start": { + "line": 48, + "column": 2, + "character": 1091 + }, + "end": { + "line": 48, + "column": 4, + "character": 1093 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 1096, + "end": 1098, + "raw": "\n\t", + "data": "\n\t" + }, + { + "type": "RegularElement", + "start": 1098, + "end": 1104, + "name": "br", + "name_loc": { + "start": { + "line": 49, + "column": 2, + "character": 1099 + }, + "end": { + "line": 49, + "column": 4, + "character": 1101 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 1104, + "end": 1112, + "raw": "\n\ttext2\n", + "data": "\n\ttext2\n" + } + ] + } + }, + { + "type": "Text", + "start": 1116, + "end": 1118, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 1118, + "end": 1162, + "data": " after a unit that renders multiline " + }, + { + "type": "Text", + "start": 1162, + "end": 1163, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 1163, + "end": 1227, + "name": "p", + "name_loc": { + "start": { + "line": 54, + "column": 1, + "character": 1164 + }, + "end": { + "line": 54, + "column": 2, + "character": 1165 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 1166, + "end": 1175, + "raw": "\n\ttext1\n\t", + "data": "\n\ttext1\n\t" + }, + { + "type": "RegularElement", + "start": 1175, + "end": 1207, + "name": "span", + "name_loc": { + "start": { + "line": 56, + "column": 2, + "character": 1176 + }, + "end": { + "line": 56, + "column": 6, + "character": 1180 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 1181, + "end": 1184, + "raw": "\n\t\t", + "data": "\n\t\t" + }, + { + "type": "RegularElement", + "start": 1184, + "end": 1198, + "name": "b", + "name_loc": { + "start": { + "line": 57, + "column": 3, + "character": 1185 + }, + "end": { + "line": 57, + "column": 4, + "character": 1186 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 1187, + "end": 1194, + "raw": "inline1", + "data": "inline1" + } + ] + } + }, + { + "type": "Text", + "start": 1198, + "end": 1200, + "raw": "\n\t", + "data": "\n\t" + } + ] + } + }, + { + "type": "Text", + "start": 1207, + "end": 1209, + "raw": "\n\t", + "data": "\n\t" + }, + { + "type": "RegularElement", + "start": 1209, + "end": 1215, + "name": "br", + "name_loc": { + "start": { + "line": 59, + "column": 2, + "character": 1210 + }, + "end": { + "line": 59, + "column": 4, + "character": 1212 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 1215, + "end": 1223, + "raw": "\n\ttext2\n", + "data": "\n\ttext2\n" + } + ] + } + }, + { + "type": "Text", + "start": 1227, + "end": 1229, + "raw": "\n\n", + "data": "\n\n" + }, + { + "type": "Comment", + "start": 1229, + "end": 1257, + "data": " an inline container " + }, + { + "type": "Text", + "start": 1257, + "end": 1258, + "raw": "\n", + "data": "\n" + }, + { + "type": "RegularElement", + "start": 1258, + "end": 1294, + "name": "span", + "name_loc": { + "start": { + "line": 64, + "column": 1, + "character": 1259 + }, + "end": { + "line": 64, + "column": 5, + "character": 1263 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [ + { + "type": "Text", + "start": 1264, + "end": 1273, + "raw": "\n\ttext1\n\t", + "data": "\n\ttext1\n\t" + }, + { + "type": "RegularElement", + "start": 1273, + "end": 1279, + "name": "br", + "name_loc": { + "start": { + "line": 66, + "column": 2, + "character": 1274 + }, + "end": { + "line": 66, + "column": 4, + "character": 1276 + } + }, + "attributes": [], + "fragment": { + "type": "Fragment", + "nodes": [] + } + }, + { + "type": "Text", + "start": 1279, + "end": 1287, + "raw": "\n\ttext2\n", + "data": "\n\ttext2\n" + } + ] + } + } + ] + }, + "options": null, + "comments": [] +} diff --git a/tests/fixtures/svelte/elements/void_br_newline/input.svelte b/tests/fixtures/svelte/elements/void_br_newline/input.svelte new file mode 100644 index 000000000..b6f8db716 --- /dev/null +++ b/tests/fixtures/svelte/elements/void_br_newline/input.svelte @@ -0,0 +1,68 @@ + + + +

+ text1 +
+ text2 +

+ + +

+ text1 text2
+ text3 text4
+ text5 text6 +

+ + +

+ text1 text2
+ text3 +

+ + +

+ text1
text2 +

+

text1
text2

+ + +

+ text1 +
+ inline1 text2 +
+ {expr} text3 +

+ + +

+ text1 +
+
+ text2 +

+ + +

+ text1 + + inline1 + +
+ text2 +

+ + + + text1 +
+ text2 +
diff --git a/tests/fixtures/svelte/elements/void_br_newline/unformatted_no_self_closing.svelte b/tests/fixtures/svelte/elements/void_br_newline/unformatted_no_self_closing.svelte new file mode 100644 index 000000000..29d1ce5e4 --- /dev/null +++ b/tests/fixtures/svelte/elements/void_br_newline/unformatted_no_self_closing.svelte @@ -0,0 +1,68 @@ + + + +

+ text1 +
+ text2 +

+ + +

+ text1 text2
+ text3 text4
+ text5 text6 +

+ + +

+ text1 text2
+ text3 +

+ + +

+ text1
text2 +

+

text1
text2

+ + +

+ text1 +
+ inline1 text2 +
+ {expr} text3 +

+ + +

+ text1 +
+
+ text2 +

+ + +

+ text1 + + inline1 + +
+ text2 +

+ + + + text1 +
+ text2 +
diff --git a/tests/fixtures/svelte/elements/void_br_newline/unformatted_spaces.svelte b/tests/fixtures/svelte/elements/void_br_newline/unformatted_spaces.svelte new file mode 100644 index 000000000..0d4ee9c37 --- /dev/null +++ b/tests/fixtures/svelte/elements/void_br_newline/unformatted_spaces.svelte @@ -0,0 +1,68 @@ + + + +

+ text1 +
+ text2 +

+ + +

+ text1 text2
+ text3 text4
+ text5 text6 +

+ + +

+ text1 text2
+ text3 +

+ + +

+ text1
text2 +

+

text1
text2

+ + +

+ text1 +
+ inline1 text2 +
+ {expr} text3 +

+ + +

+ text1 +
+
+ text2 +

+ + +

+ text1 + + inline1 + +
+ text2 +

+ + + + text1 +
+ text2 +