MCPcopy Create free account
hub / github.com/markdoc/markdoc / parseTag

Function parseTag

src/utils.ts:54–70  ·  view source on GitHub ↗
(content: string, line: number, contentStart: number)

Source from the content-addressed store, hash-verified

52}
53
54function parseTag(content: string, line: number, contentStart: number) {
55 try {
56 return parse(content, { Variable, Function });
57 } catch (error) {
58 if (!(error instanceof SyntaxError)) throw error;
59 const {
60 message,
61 location: { start, end },
62 } = error as SyntaxError;
63 const location = {
64 start: { line, character: start.offset + contentStart },
65 end: { line: line + 1, character: end.offset + contentStart },
66 };
67
68 return { type: 'error', meta: { error: { message, location } } };
69 }
70}
71
72export function parseTags(content: string, firstLine = 0): Token[] {
73 let line = firstLine + 1;

Callers 1

parseTagsFunction · 0.85

Calls 1

parseFunction · 0.50

Tested by

no test coverage detected