@herb-tools/formatter 0.6.1 → 0.7.0
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 +59 -19
- package/dist/herb-format.js.map +1 -1
- package/dist/index.cjs +19 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +19 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/cli.ts +4 -2
- package/src/format-printer.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/formatter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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.
|
|
39
|
-
"@herb-tools/printer": "0.
|
|
38
|
+
"@herb-tools/core": "0.7.0",
|
|
39
|
+
"@herb-tools/printer": "0.7.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"glob": "^11.0.3"
|
package/src/cli.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { join, resolve } from "path"
|
|
|
6
6
|
import { Herb } from "@herb-tools/node-wasm"
|
|
7
7
|
import { Formatter } from "./formatter.js"
|
|
8
8
|
|
|
9
|
-
import { name, version } from "../package.json"
|
|
9
|
+
import { name, version, dependencies } from "../package.json"
|
|
10
10
|
|
|
11
11
|
const pluralize = (count: number, singular: string, plural: string = singular + 's'): string => {
|
|
12
12
|
return count === 1 ? singular : plural
|
|
@@ -52,7 +52,9 @@ export class CLI {
|
|
|
52
52
|
|
|
53
53
|
if (args.includes("--version") || args.includes("-v")) {
|
|
54
54
|
console.log("Versions:")
|
|
55
|
-
console.log(` ${name}@${version}
|
|
55
|
+
console.log(` ${name}@${version}`)
|
|
56
|
+
console.log(` @herb-tools/printer@${dependencies['@herb-tools/printer']}`)
|
|
57
|
+
console.log(` ${Herb.version}`.split(", ").join("\n "))
|
|
56
58
|
|
|
57
59
|
process.exit(0)
|
|
58
60
|
}
|
package/src/format-printer.ts
CHANGED
|
@@ -956,9 +956,9 @@ export class FormatPrinter extends Printer {
|
|
|
956
956
|
|
|
957
957
|
if (node.children && node.children.length > 0) {
|
|
958
958
|
inner = node.children.map(child => {
|
|
959
|
-
if (isNode(child, HTMLTextNode) ||
|
|
959
|
+
if (isNode(child, HTMLTextNode) || isNode(child, LiteralNode)) {
|
|
960
960
|
return child.content
|
|
961
|
-
} else if (isERBNode(child) ||
|
|
961
|
+
} else if (isERBNode(child) || isNode(child, ERBContentNode)) {
|
|
962
962
|
return this.reconstructERBNode(child, false)
|
|
963
963
|
} else {
|
|
964
964
|
return ""
|
|
@@ -1226,7 +1226,7 @@ export class FormatPrinter extends Printer {
|
|
|
1226
1226
|
* Determines if the open tag should be rendered inline
|
|
1227
1227
|
*/
|
|
1228
1228
|
private shouldRenderOpenTagInline(node: HTMLElementNode): boolean {
|
|
1229
|
-
const children = node.open_tag?.children ||
|
|
1229
|
+
const children = node.open_tag?.children || []
|
|
1230
1230
|
const attributes = filterNodes(children, HTMLAttributeNode)
|
|
1231
1231
|
const inlineNodes = this.extractInlineNodes(children)
|
|
1232
1232
|
const hasERBControlFlow = inlineNodes.some(node => isERBControlFlowNode(node)) || children.some(node => isERBControlFlowNode(node))
|
|
@@ -1555,7 +1555,7 @@ export class FormatPrinter extends Printer {
|
|
|
1555
1555
|
let htmlTextContent = ""
|
|
1556
1556
|
|
|
1557
1557
|
const content = attributeValue.children.map((child: Node) => {
|
|
1558
|
-
if (isNode(child, HTMLTextNode) ||
|
|
1558
|
+
if (isNode(child, HTMLTextNode) || isNode(child, LiteralNode)) {
|
|
1559
1559
|
htmlTextContent += child.content
|
|
1560
1560
|
|
|
1561
1561
|
return child.content
|