MCPcopy Index your code
hub / github.com/markdoc/markdoc / parser

Function parser

src/parser.ts:199–219  ·  view source on GitHub ↗
(tokens: Token[], args?: string | ParserArgs)

Source from the content-addressed store, hash-verified

197}
198
199export default function parser(tokens: Token[], args?: string | ParserArgs) {
200 const doc = new Node('document');
201 const nodes = [doc];
202
203 if (typeof args === 'string') args = { file: args };
204
205 for (const token of tokens)
206 handleToken(token, nodes, args?.file, args?.slots, args?.location);
207
208 if (nodes.length > 1)
209 for (const node of nodes.slice(1))
210 node.errors.push({
211 id: 'missing-closing',
212 level: 'critical',
213 message: `Node '${node.tag || node.type}' is missing closing`,
214 });
215
216 for (const transform of transforms) transform(doc, args?.conditionalTags);
217
218 return doc;
219}

Callers 2

parseFunction · 0.85
convertFunction · 0.85

Calls 3

handleTokenFunction · 0.85
pushMethod · 0.80
transformFunction · 0.70

Tested by 1

convertFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…