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

Function core

src/tokenizer/plugins/annotations.ts:96–131  ·  view source on GitHub ↗
(state: StateCore)

Source from the content-addressed store, hash-verified

94}
95
96function core(state: StateCore) {
97 let token: Token;
98 for (token of state.tokens) {
99 if (token.type !== 'fence') continue;
100
101 if (token.info.includes(OPEN)) {
102 const start = token.info.indexOf(OPEN);
103 const end = findTagEnd(token.info, start);
104 const content = token.info.slice(start + OPEN.length, end);
105
106 try {
107 const { meta } = parse(content.trim(), { Variable, Function });
108 token.meta = meta;
109 } catch (error) {
110 if (!(error instanceof SyntaxError)) throw error;
111 if (!token.errors) token.errors = [];
112 token.errors.push({
113 id: 'fence-tag-error',
114 level: 'error',
115 message: `Syntax error in fence tag: ${
116 (error as SyntaxError).message
117 }`,
118 });
119 }
120 }
121
122 if (
123 token?.meta?.attributes?.find(
124 (attr: AttributeValue) => attr.name === 'process' && !attr.value
125 )
126 )
127 continue;
128
129 token.children = parseTags(token.content, token.map[0]);
130 }
131}
132
133export default function plugin(md: MarkdownIt /* options */) {
134 md.block.ruler.before('paragraph', 'annotations', block, {

Callers

nothing calls this directly

Calls 4

findTagEndFunction · 0.90
parseTagsFunction · 0.90
pushMethod · 0.80
parseFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…