(path, options)
| 34 | ]); |
| 35 | |
| 36 | function embed(path, options) { |
| 37 | const { node } = path; |
| 38 | |
| 39 | switch (node.kind) { |
| 40 | case "element": |
| 41 | if (isScriptLikeTag(node, options) || node.kind === "interpolation") { |
| 42 | // Fall through to "text" |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | if (!node.isSelfClosing && isVueNonHtmlBlock(node, options)) { |
| 47 | const parser = inferElementParser(node, options); |
| 48 | if (!parser) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | return async (textToDoc, print) => { |
| 53 | const content = getNodeContent(node, options); |
| 54 | let isEmpty = /^\s*$/.test(content); |
| 55 | let doc = ""; |
| 56 | if (!isEmpty) { |
| 57 | doc = await textToDoc(htmlTrimPreserveIndentation(content), { |
| 58 | parser, |
| 59 | __embeddedInHtml: true, |
| 60 | }); |
| 61 | isEmpty = doc === ""; |
| 62 | } |
| 63 | |
| 64 | return [ |
| 65 | printOpeningTagPrefix(node, options), |
| 66 | group(printOpeningTag(path, options, print)), |
| 67 | isEmpty ? "" : hardline, |
| 68 | doc, |
| 69 | isEmpty ? "" : hardline, |
| 70 | printClosingTag(node, options), |
| 71 | printClosingTagSuffix(node, options), |
| 72 | ]; |
| 73 | }; |
| 74 | } |
| 75 | break; |
| 76 | |
| 77 | case "text": |
| 78 | if (isScriptLikeTag(node.parent, options)) { |
| 79 | const parser = inferElementParser(node.parent, options); |
| 80 | if (parser) { |
| 81 | return async (textToDoc) => { |
| 82 | const value = |
| 83 | parser === "markdown" |
| 84 | ? htmlWhitespace.dedentString( |
| 85 | node.value.replace(/^[^\S\n]*\n/, ""), |
| 86 | ) |
| 87 | : node.value; |
| 88 | const textToDocOptions = { parser, __embeddedInHtml: true }; |
| 89 | if (options.parser === "html" && parser === "babel") { |
| 90 | let sourceType = "script"; |
| 91 | const { attrMap } = node.parent; |
| 92 | if ( |
| 93 | attrMap && |
nothing calls this directly
no test coverage detected
searching dependent graphs…