MCPcopy Index your code
hub / github.com/lingodotdev/lingo.dev / createBracketAwareTextNodes

Function createBracketAwareTextNodes

scripts/docs/src/generate-cli-docs.ts:114–140  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

112}
113
114function createBracketAwareTextNodes(text: string): PhrasingContent[] {
115 const nodes: PhrasingContent[] = [];
116 const bracketPattern = /\[[^\]]+\]/g;
117 let lastIndex = 0;
118
119 for (const match of text.matchAll(bracketPattern)) {
120 const [value] = match;
121 const start = match.index ?? 0;
122
123 if (start > lastIndex) {
124 nodes.push({ type: "text", value: text.slice(lastIndex, start) });
125 }
126
127 nodes.push(createInlineCode(value));
128 lastIndex = start + value.length;
129 }
130
131 if (lastIndex < text.length) {
132 nodes.push({ type: "text", value: text.slice(lastIndex) });
133 }
134
135 if (nodes.length === 0) {
136 nodes.push({ type: "text", value: text });
137 }
138
139 return nodes;
140}
141
142function createList(items: ListItem[]): List {
143 return {

Callers 1

createTextNodesFunction · 0.85

Calls 2

createInlineCodeFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…