Sha256: 2bd51ce8f2e5b046925b9d1e8c0e09c6f8cb84232fd385b3359af76c4ca961b6
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
const { concat, hardline, indent, literalline, mapDoc, markAsRoot, stripTrailingHardline } = require("../prettier"); const parsers = { css: "css", javascript: "babel", less: "less", markdown: "markdown", ruby: "ruby", scss: "scss" }; const replaceNewlines = (doc) => mapDoc(doc, (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat( currentDoc .split(/(\n)/g) .map((v, i) => (i % 2 === 0 ? v : literalline)) ) : currentDoc ); const embed = (path, print, textToDoc, _opts) => { const node = path.getValue(); if (node.type !== "filter") { return null; } const parser = parsers[node.value.name]; if (!parser) { return null; } return markAsRoot( concat([ ":", node.value.name, indent( concat([ hardline, replaceNewlines( stripTrailingHardline(textToDoc(node.value.text, { parser })) ) ]) ) ]) ); }; module.exports = embed;
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
prettier-0.20.0 | src/haml/embed.js |
prettier-0.19.1 | src/haml/embed.js |
prettier-0.19.0 | src/haml/embed.js |
prettier-0.18.2 | src/haml/embed.js |
prettier-0.18.1 | src/haml/embed.js |