MCPcopy
hub / github.com/prettier/prettier / printChildren

Function printChildren

src/language-html/print/children.js:166–260  ·  view source on GitHub ↗
(path, options, print)

Source from the content-addressed store, hash-verified

164}
165
166function printChildren(path, options, print) {
167 const { node } = path;
168
169 if (forceBreakChildren(node)) {
170 return [
171 breakParent,
172
173 ...path.map(() => {
174 const childNode = path.node;
175 const prevBetweenLine = !childNode.prev
176 ? ""
177 : printBetweenLine(childNode.prev, childNode);
178 return [
179 !prevBetweenLine
180 ? ""
181 : [
182 prevBetweenLine,
183 forceNextEmptyLine(childNode.prev) ? hardline : "",
184 ],
185 printChild(path, options, print),
186 ];
187 }, "children"),
188 ];
189 }
190
191 const groupIds = node.children.map(() => Symbol(""));
192 return path.map(({ node: childNode, index: childIndex }) => {
193 if (isTextLikeNode(childNode)) {
194 if (childNode.prev && isTextLikeNode(childNode.prev)) {
195 const prevBetweenLine = printBetweenLine(childNode.prev, childNode);
196 if (prevBetweenLine) {
197 if (forceNextEmptyLine(childNode.prev)) {
198 return [hardline, hardline, printChild(path, options, print)];
199 }
200 return [prevBetweenLine, printChild(path, options, print)];
201 }
202 }
203 return printChild(path, options, print);
204 }
205
206 const prevParts = [];
207 const leadingParts = [];
208 const trailingParts = [];
209 const nextParts = [];
210
211 const prevBetweenLine = childNode.prev
212 ? printBetweenLine(childNode.prev, childNode)
213 : "";
214
215 const nextBetweenLine = childNode.next
216 ? printBetweenLine(childNode, childNode.next)
217 : "";
218
219 if (prevBetweenLine) {
220 if (forceNextEmptyLine(childNode.prev)) {
221 prevParts.push(hardline, hardline);
222 } else if (prevBetweenLine === hardline) {
223 prevParts.push(hardline);

Callers 3

genericPrintFunction · 0.90
printElementFunction · 0.90

Calls 8

forceBreakChildrenFunction · 0.90
forceNextEmptyLineFunction · 0.90
isTextLikeNodeFunction · 0.90
ifBreakFunction · 0.90
groupFunction · 0.90
printBetweenLineFunction · 0.85
printChildFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…