MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / stringify

Function stringify

packages/ast/stringify/index.js:3–91  ·  view source on GitHub ↗
(tree)

Source from the content-addressed store, hash-verified

1const walk = require('../walk');
2
3function stringify(tree) {
4 let output = '';
5
6 walk(tree, (node) => {
7 if (node.used) {
8 return;
9 }
10 node.used = true;
11 if (node.type === 'root') {
12 return;
13 }
14 if (node.type === 'bold') {
15 output += '*';
16 node.children.forEach((child) => {
17 output += stringify(child);
18 });
19 output += '*';
20 }
21
22 if (node.type === 'italic') {
23 output += '_';
24 node.children.forEach((child) => {
25 output += stringify(child);
26 });
27 output += '_';
28 }
29
30 if (node.type === 'strike') {
31 output += '~';
32 node.children.forEach((child) => {
33 output += stringify(child);
34 });
35 output += '~';
36 }
37
38 if (node.type === 'code') {
39 output += node.source;
40 }
41
42 if (node.type === 'pre') {
43 output += node.source;
44 }
45
46 if (node.type === 'quote') {
47 output += '> ';
48 node.children.forEach((child) => {
49 output += stringify(child);
50 });
51 }
52
53 if (node.type === 'header') {
54 output += `${'#'.repeat(node.depth)} `;
55 node.children.forEach((child) => {
56 output += stringify(child);
57 });
58 }
59
60 if (node.type === 'list') {

Callers 9

inbound.tsFile · 0.85
sendMailFunction · 0.85
index.spec.jsFile · 0.85
postprocessFunction · 0.85
preprocessFunction · 0.85
inbound.tsFile · 0.85
eventThreadClosedFunction · 0.85
eventThreadReopenedFunction · 0.85
integrationMiddlewareFunction · 0.85

Calls 2

walkFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected