@herb-tools/formatter 0.8.2 → 0.8.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/dist/herb-format.js +151 -61
- package/dist/herb-format.js.map +1 -1
- package/dist/index.cjs +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +22 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -5
- package/src/cli.ts +3 -2
- package/src/format-printer.ts +25 -1
package/dist/index.esm.js
CHANGED
|
@@ -241,7 +241,7 @@ class Token {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
244
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
244
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/errors.ts.erb
|
|
245
245
|
class HerbError {
|
|
246
246
|
type;
|
|
247
247
|
message;
|
|
@@ -771,7 +771,7 @@ function convertToUTF8(string) {
|
|
|
771
771
|
}
|
|
772
772
|
|
|
773
773
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
774
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
774
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/nodes.ts.erb
|
|
775
775
|
class Node {
|
|
776
776
|
type;
|
|
777
777
|
location;
|
|
@@ -3005,7 +3005,7 @@ class ParseResult extends Result {
|
|
|
3005
3005
|
}
|
|
3006
3006
|
|
|
3007
3007
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
3008
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
3008
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/node-type-guards.ts.erb
|
|
3009
3009
|
/**
|
|
3010
3010
|
* Type guard functions for AST nodes.
|
|
3011
3011
|
* These functions provide type checking by combining both instanceof
|
|
@@ -3502,7 +3502,7 @@ function getNodesAfterPosition(nodes, position, inclusive = true) {
|
|
|
3502
3502
|
}
|
|
3503
3503
|
|
|
3504
3504
|
// NOTE: This file is generated by the templates/template.rb script and should not
|
|
3505
|
-
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.
|
|
3505
|
+
// be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/visitor.ts.erb
|
|
3506
3506
|
class Visitor {
|
|
3507
3507
|
visit(node) {
|
|
3508
3508
|
if (!node)
|
|
@@ -4985,13 +4985,30 @@ class FormatPrinter extends Printer {
|
|
|
4985
4985
|
* Render multiline attributes for a tag
|
|
4986
4986
|
*/
|
|
4987
4987
|
renderMultilineAttributes(tagName, allChildren = [], isSelfClosing = false) {
|
|
4988
|
-
|
|
4988
|
+
const herbDisableComments = allChildren.filter(child => isNode(child, ERBContentNode) && isHerbDisableComment(child));
|
|
4989
|
+
let openingLine = `<${tagName}`;
|
|
4990
|
+
if (herbDisableComments.length > 0) {
|
|
4991
|
+
const commentLines = this.capture(() => {
|
|
4992
|
+
herbDisableComments.forEach(comment => {
|
|
4993
|
+
const wasInlineMode = this.inlineMode;
|
|
4994
|
+
this.inlineMode = true;
|
|
4995
|
+
this.lines.push(" ");
|
|
4996
|
+
this.visit(comment);
|
|
4997
|
+
this.inlineMode = wasInlineMode;
|
|
4998
|
+
});
|
|
4999
|
+
});
|
|
5000
|
+
openingLine += commentLines.join("");
|
|
5001
|
+
}
|
|
5002
|
+
this.pushWithIndent(openingLine);
|
|
4989
5003
|
this.withIndent(() => {
|
|
4990
5004
|
allChildren.forEach(child => {
|
|
4991
5005
|
if (isNode(child, HTMLAttributeNode)) {
|
|
4992
5006
|
this.pushWithIndent(this.renderAttribute(child));
|
|
4993
5007
|
}
|
|
4994
5008
|
else if (!isNode(child, WhitespaceNode)) {
|
|
5009
|
+
if (isNode(child, ERBContentNode) && isHerbDisableComment(child)) {
|
|
5010
|
+
return;
|
|
5011
|
+
}
|
|
4995
5012
|
this.visit(child);
|
|
4996
5013
|
}
|
|
4997
5014
|
});
|