MCPcopy
hub / github.com/garrytan/gstack / parseLine

Function parseLine

browse/src/snapshot.ts:118–133  ·  view source on GitHub ↗

* Parse one line of ariaSnapshot output. * * Format examples: * - heading "Test" [level=1] * - link "Link A": * - /url: /a * - textbox "Name" * - paragraph: Some text * - combobox "Role":

(line: string)

Source from the content-addressed store, hash-verified

116 * - combobox "Role":
117 */
118function parseLine(line: string): ParsedNode | null {
119 // Match: (indent)(- )(role)( "name")?( [props])?(: inline)?
120 const match = line.match(/^(\s*)-\s+(\w+)(?:\s+"([^"]*)")?(?:\s+(\[.*?\]))?\s*(?::\s*(.*))?$/);
121 if (!match) {
122 // Skip metadata lines like "- /url: /a"
123 return null;
124 }
125 return {
126 indent: match[1].length,
127 role: match[2],
128 name: match[3] ?? null,
129 props: match[4] || '',
130 children: match[5]?.trim() || '',
131 rawLine: line,
132 };
133}
134
135/**
136 * Take an accessibility snapshot and build the ref map.

Callers 1

handleSnapshotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected