MCPcopy
hub / github.com/prettier/prettier / getFencedCodeBlockValue

Function getFencedCodeBlockValue

src/language-markdown/utilities.js:231–242  ·  view source on GitHub ↗
(node, originalText)

Source from the content-addressed store, hash-verified

229// https://github.com/remarkjs/remark/issues/512
230// TODO[@fisker]: Use `node.value` directly when we update mdx to use latest remark
231function getFencedCodeBlockValue(node, originalText) {
232 const { value } = node;
233 if (
234 node.position.end.offset === originalText.length &&
235 value.endsWith("\n") &&
236 // Code block has no end mark
237 originalText.endsWith("\n")
238 ) {
239 return value.slice(0, -1);
240 }
241 return value;
242}
243
244function mapAst(ast, handler) {
245 return (function preorder(node, index, parentStack) {

Callers 2

embedFunction · 0.90
printMdastFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…