@herb-tools/formatter 0.9.0 → 0.9.1
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/dist/herb-format.js +1068 -16
- package/dist/herb-format.js.map +1 -1
- package/dist/index.cjs +551 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +551 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/types/format-printer.d.ts +3 -1
- package/package.json +5 -5
- package/src/format-printer.ts +10 -0
|
@@ -3,7 +3,7 @@ import type { ERBNode } from "@herb-tools/core";
|
|
|
3
3
|
import type { FormatOptions } from "./options.js";
|
|
4
4
|
import type { TextFlowDelegate } from "./text-flow-engine.js";
|
|
5
5
|
import type { AttributeRendererDelegate } from "./attribute-renderer.js";
|
|
6
|
-
import { ParseResult, Node, DocumentNode, HTMLOpenTagNode, HTMLConditionalOpenTagNode, HTMLCloseTagNode, HTMLElementNode, HTMLConditionalElementNode, HTMLAttributeNode, HTMLAttributeValueNode, HTMLAttributeNameNode, HTMLTextNode, HTMLCommentNode, HTMLDoctypeNode, ERBContentNode, ERBBlockNode, ERBEndNode, ERBElseNode, ERBIfNode, ERBWhenNode, ERBCaseNode, ERBCaseMatchNode, ERBWhileNode, ERBUntilNode, ERBForNode, ERBRescueNode, ERBEnsureNode, ERBBeginNode, ERBUnlessNode, ERBYieldNode, ERBInNode, ERBOpenTagNode, HTMLVirtualCloseTagNode, XMLDeclarationNode, CDATANode, Token } from "@herb-tools/core";
|
|
6
|
+
import { ParseResult, Node, DocumentNode, HTMLOpenTagNode, HTMLConditionalOpenTagNode, HTMLCloseTagNode, HTMLElementNode, HTMLConditionalElementNode, HTMLAttributeNode, HTMLAttributeValueNode, HTMLAttributeNameNode, HTMLTextNode, HTMLCommentNode, HTMLDoctypeNode, ERBContentNode, ERBBlockNode, ERBEndNode, ERBElseNode, ERBIfNode, ERBWhenNode, ERBCaseNode, ERBCaseMatchNode, ERBWhileNode, ERBUntilNode, ERBForNode, ERBRescueNode, ERBEnsureNode, ERBBeginNode, ERBUnlessNode, ERBYieldNode, ERBInNode, ERBRenderNode, RubyRenderLocalNode, ERBOpenTagNode, HTMLVirtualCloseTagNode, XMLDeclarationNode, CDATANode, Token } from "@herb-tools/core";
|
|
7
7
|
/**
|
|
8
8
|
* Printer traverses the Herb AST using the Visitor pattern
|
|
9
9
|
* and emits a formatted string with proper indentation, line breaks, and attribute wrapping.
|
|
@@ -131,6 +131,8 @@ export declare class FormatPrinter extends Printer implements TextFlowDelegate,
|
|
|
131
131
|
visitERBOpenTagNode(node: ERBOpenTagNode): void;
|
|
132
132
|
visitHTMLVirtualCloseTagNode(_node: HTMLVirtualCloseTagNode): void;
|
|
133
133
|
visitERBEndNode(node: ERBEndNode): void;
|
|
134
|
+
visitERBRenderNode(node: ERBRenderNode): void;
|
|
135
|
+
visitRubyRenderLocalNode(_node: RubyRenderLocalNode): void;
|
|
134
136
|
visitERBYieldNode(node: ERBYieldNode): void;
|
|
135
137
|
visitERBInNode(node: ERBInNode): void;
|
|
136
138
|
visitERBCaseMatchNode(node: ERBCaseMatchNode): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/formatter",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
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,10 +35,10 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@herb-tools/config": "0.9.
|
|
39
|
-
"@herb-tools/core": "0.9.
|
|
40
|
-
"@herb-tools/printer": "0.9.
|
|
41
|
-
"@herb-tools/rewriter": "0.9.
|
|
38
|
+
"@herb-tools/config": "0.9.1",
|
|
39
|
+
"@herb-tools/core": "0.9.1",
|
|
40
|
+
"@herb-tools/printer": "0.9.1",
|
|
41
|
+
"@herb-tools/rewriter": "0.9.1",
|
|
42
42
|
"tinyglobby": "^0.2.15"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
package/src/format-printer.ts
CHANGED
|
@@ -87,6 +87,8 @@ import {
|
|
|
87
87
|
ERBUnlessNode,
|
|
88
88
|
ERBYieldNode,
|
|
89
89
|
ERBInNode,
|
|
90
|
+
ERBRenderNode,
|
|
91
|
+
RubyRenderLocalNode,
|
|
90
92
|
ERBOpenTagNode,
|
|
91
93
|
HTMLVirtualCloseTagNode,
|
|
92
94
|
XMLDeclarationNode,
|
|
@@ -1019,6 +1021,14 @@ export class FormatPrinter extends Printer implements TextFlowDelegate, Attribut
|
|
|
1019
1021
|
this.printERBNode(node)
|
|
1020
1022
|
}
|
|
1021
1023
|
|
|
1024
|
+
visitERBRenderNode(node: ERBRenderNode) {
|
|
1025
|
+
this.printERBNode(node)
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
visitRubyRenderLocalNode(_node: RubyRenderLocalNode) {
|
|
1029
|
+
// extracted metadata, nothing to print
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1022
1032
|
visitERBYieldNode(node: ERBYieldNode) {
|
|
1023
1033
|
this.trackBoundary(node, () => {
|
|
1024
1034
|
this.printERBNode(node)
|