MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / parseCallout

Method parseCallout

src/common/markdown-block.ts:136–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

134 }
135
136 parseCallout(): TaggedCallout {
137 const typeMatch = this.readUntil('\n')
138 .trim()
139 .match(/^(info|warning|error)\s*(.*)$/);
140 if (!typeMatch) {
141 throw new Error('Invalid callout type');
142 }
143 const type = typeMatch[1] as 'info' | 'warning' | 'error';
144 const labelText = typeMatch[2];
145 const labelParsed = parseSpan(labelText);
146 const contentLines: string[] = [];
147 while (!this.atEnd()) {
148 const lineStartPos = this.pos;
149 if (this.match(':::')) {
150 if (this.peek() === '\n') this.consume();
151 break;
152 } else {
153 this.pos = lineStartPos;
154 }
155 const line = this.readUntil('\n');
156 contentLines.push(line);
157 if (!this.atEnd()) this.consume(); // Consume the newline
158 }
159 const contentString = contentLines.join('\n');
160 const nestedParser = new MarkdownParser(contentString);
161 const contentBlocks = nestedParser.parseBlocks();
162 return {
163 tag: 'callout',
164 type,
165 label: labelParsed,
166 content: contentBlocks,
167 };
168 }
169
170 parseList(): TaggedList {
171 const items: TaggedText[][] = [];

Callers 1

parseBlockMethod · 0.95

Calls 7

readUntilMethod · 0.95
parseBlocksMethod · 0.95
parseSpanFunction · 0.90
consumeMethod · 0.80
matchMethod · 0.65
atEndMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected