@herb-tools/formatter 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herb-tools/formatter",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "Auto-formatter for HTML+ERB templates with intelligent indentation, line wrapping, and ERB-aware pretty-printing.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://herb-tools.dev",
@@ -35,8 +35,8 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@herb-tools/core": "0.7.2",
39
- "@herb-tools/printer": "0.7.2"
38
+ "@herb-tools/core": "0.7.4",
39
+ "@herb-tools/printer": "0.7.4"
40
40
  },
41
41
  "devDependencies": {
42
42
  "glob": "^11.0.3"
@@ -730,7 +730,19 @@ export class FormatPrinter extends Printer {
730
730
 
731
731
  visitHTMLElementBody(body: Node[], element: HTMLElementNode) {
732
732
  if (this.isContentPreserving(element)) {
733
- element.body.map(child => this.pushToLastLine(IdentityPrinter.print(child)))
733
+ element.body.map(child => {
734
+ if (isNode(child, HTMLElementNode)) {
735
+ const wasInlineMode = this.inlineMode
736
+ this.inlineMode = true
737
+
738
+ const formattedElement = this.capture(() => this.visit(child)).join("")
739
+ this.pushToLastLine(formattedElement)
740
+
741
+ this.inlineMode = wasInlineMode
742
+ } else {
743
+ this.pushToLastLine(IdentityPrinter.print(child))
744
+ }
745
+ })
734
746
 
735
747
  return
736
748
  }
@@ -1560,7 +1572,7 @@ export class FormatPrinter extends Printer {
1560
1572
 
1561
1573
  return child.content
1562
1574
  } else if (isNode(child, ERBContentNode)) {
1563
- return IdentityPrinter.print(child)
1575
+ return this.reconstructERBNode(child, true)
1564
1576
  } else {
1565
1577
  const printed = IdentityPrinter.print(child)
1566
1578