@herb-tools/formatter 0.8.8 → 0.8.10
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 +98 -25
- package/dist/herb-format.js.map +1 -1
- package/dist/index.cjs +46 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +46 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/types/format-printer.d.ts +2 -1
- package/package.json +5 -5
- package/src/format-printer.ts +9 -2
|
@@ -69,7 +69,8 @@ export declare class FormatPrinter extends Printer {
|
|
|
69
69
|
private get indent();
|
|
70
70
|
/**
|
|
71
71
|
* Format ERB content with proper spacing around the inner content.
|
|
72
|
-
* Returns empty string if content is empty, otherwise
|
|
72
|
+
* Returns empty string if content is empty, otherwise adds a leading space
|
|
73
|
+
* and a trailing space (or newline for heredoc content starting with "<<").
|
|
73
74
|
*/
|
|
74
75
|
private formatERBContent;
|
|
75
76
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herb-tools/formatter",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.10",
|
|
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.8.
|
|
39
|
-
"@herb-tools/core": "0.8.
|
|
40
|
-
"@herb-tools/printer": "0.8.
|
|
41
|
-
"@herb-tools/rewriter": "0.8.
|
|
38
|
+
"@herb-tools/config": "0.8.10",
|
|
39
|
+
"@herb-tools/core": "0.8.10",
|
|
40
|
+
"@herb-tools/printer": "0.8.10",
|
|
41
|
+
"@herb-tools/rewriter": "0.8.10",
|
|
42
42
|
"tinyglobby": "^0.2.15"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
package/src/format-printer.ts
CHANGED
|
@@ -285,10 +285,17 @@ export class FormatPrinter extends Printer {
|
|
|
285
285
|
|
|
286
286
|
/**
|
|
287
287
|
* Format ERB content with proper spacing around the inner content.
|
|
288
|
-
* Returns empty string if content is empty, otherwise
|
|
288
|
+
* Returns empty string if content is empty, otherwise adds a leading space
|
|
289
|
+
* and a trailing space (or newline for heredoc content starting with "<<").
|
|
289
290
|
*/
|
|
290
291
|
private formatERBContent(content: string): string {
|
|
291
|
-
|
|
292
|
+
let trimmedContent = content.trim();
|
|
293
|
+
|
|
294
|
+
// See: https://github.com/marcoroth/herb/issues/476
|
|
295
|
+
// TODO: revisit once we have access to Prism nodes
|
|
296
|
+
let suffix = trimmedContent.startsWith("<<") ? "\n" : " "
|
|
297
|
+
|
|
298
|
+
return trimmedContent ? ` ${trimmedContent}${suffix}` : ""
|
|
292
299
|
}
|
|
293
300
|
|
|
294
301
|
/**
|