Sha256: b20a2c411e78f0784fabe548201652dbbfcc25893710501b4356b6deac6abb49
Contents?: true
Size: 1.03 KB
Versions: 3
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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
prettier-0.18.0 | src/haml/embed.js |
prettier-0.17.0 | src/haml/embed.js |
prettier-0.16.0 | src/haml/embed.js |