MCPcopy
hub / github.com/marktext/marktext / visit

Function visit

packages/muya/src/state/__tests__/referenceLink.spec.ts:14–32  ·  view source on GitHub ↗
(sts: TState[])

Source from the content-addressed store, hash-verified

12 const labels = new Map<string, { href: string; title: string }>();
13
14 const visit = (sts: TState[]) => {
15 for (const st of sts) {
16 if (st.name === 'paragraph') {
17 const tokens = beginRules.reference_definition.exec(st.text);
18 if (tokens) {
19 const label = (tokens[2] + tokens[3]).toLowerCase();
20 if (!labels.has(label)) {
21 labels.set(label, {
22 href: tokens[6],
23 title: tokens[10] || '',
24 });
25 }
26 }
27 }
28 else if ((st as TContainerState).children) {
29 visit((st as TContainerState).children);
30 }
31 }
32 };
33
34 visit(states);
35 return labels;

Callers 2

collectLabelsFunction · 0.85
transformTreeFunction · 0.85

Calls 1

hasMethod · 0.65

Tested by

no test coverage detected