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

Function annotate

src/parser.ts:17–34  ·  view source on GitHub ↗
(node: Node, attributes: AttributeValue[])

Source from the content-addressed store, hash-verified

15};
16
17function annotate(node: Node, attributes: AttributeValue[]) {
18 for (const attribute of attributes) {
19 node.annotations.push(attribute);
20
21 const { name, value, type } = attribute;
22 if (type === 'attribute') {
23 if (node.attributes[name] !== undefined)
24 node.errors.push({
25 id: 'duplicate-attribute',
26 level: 'warning',
27 message: `Attribute '${name}' already set`,
28 });
29 node.attributes[name] = value;
30 } else if (type === 'class')
31 if (node.attributes.class) node.attributes.class[name] = value;
32 else node.attributes.class = { [name]: value };
33 }
34}
35
36function handleAttrs(token: Token, type: string) {
37 switch (type) {

Callers 1

handleTokenFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…