(path, options, print)
| 43 | } from "./utilities/index.js"; |
| 44 | |
| 45 | function genericPrint(path, options, print) { |
| 46 | const { node } = path; |
| 47 | |
| 48 | switch (node.kind) { |
| 49 | case "root": |
| 50 | if (options.__onHtmlRoot) { |
| 51 | options.__onHtmlRoot(node); |
| 52 | } |
| 53 | return [group(printChildren(path, options, print)), hardline]; |
| 54 | case "element": |
| 55 | case "ieConditionalComment": |
| 56 | return printElement(path, options, print); |
| 57 | |
| 58 | case "angularControlFlowBlock": |
| 59 | return printAngularControlFlowBlock(path, options, print); |
| 60 | case "angularControlFlowBlockParameters": |
| 61 | return printAngularControlFlowBlockParameters(path, options, print); |
| 62 | case "angularControlFlowBlockParameter": |
| 63 | return htmlWhitespace.trim(node.expression); |
| 64 | |
| 65 | case "angularLetDeclaration": |
| 66 | // print like "break-after-operator" layout assignment in estree printer |
| 67 | return group([ |
| 68 | "@let ", |
| 69 | group([node.id, " =", group(indent([line, print("init")]))]), |
| 70 | // semicolon is required |
| 71 | ";", |
| 72 | ]); |
| 73 | case "angularLetDeclarationInitializer": |
| 74 | // basically printed via embedded formatting |
| 75 | return node.value; |
| 76 | |
| 77 | case "angularIcuExpression": |
| 78 | return printAngularIcuExpression(path, options, print); |
| 79 | case "angularIcuCase": |
| 80 | return printAngularIcuCase(path, options, print); |
| 81 | |
| 82 | case "ieConditionalStartComment": |
| 83 | case "ieConditionalEndComment": |
| 84 | return [printOpeningTagStart(node), printClosingTagEnd(node)]; |
| 85 | case "interpolation": |
| 86 | return [ |
| 87 | printOpeningTagStart(node, options), |
| 88 | ...path.map(print, "children"), |
| 89 | printClosingTagEnd(node, options), |
| 90 | ]; |
| 91 | case "text": { |
| 92 | if (node.parent.kind === "interpolation") { |
| 93 | // replace the trailing literalline with hardline for better readability |
| 94 | const trailingNewlineRegex = /\n[^\S\n]*$/; |
| 95 | const hasTrailingNewline = trailingNewlineRegex.test(node.value); |
| 96 | const value = hasTrailingNewline |
| 97 | ? node.value.replace(trailingNewlineRegex, "") |
| 98 | : node.value; |
| 99 | return [replaceEndOfLine(value), hasTrailingNewline ? hardline : ""]; |
| 100 | } |
| 101 | |
| 102 | const prefix = printOpeningTagPrefix(node, options); |
nothing calls this directly
no test coverage detected
searching dependent graphs…