Tags: ttab/newsdoc
Tags
feat(value-extractor): add inline child selector '#(...)' (#17) * feat(value-extractor): add inline child selector '#(...)' Add an inline per-selector descendant-existence check `#(...)` that gates a selector on having matching children without terminating the outer chain or changing what is yielded. This complements the existing terminal `#` form, which ends the chain and yields the descendants instead. - Add BlockSelector.RequireChild, evaluated via the existing hasMatchingChildren in BlockSelector.Matches; supports nesting and the same filters as the terminal form. - Replace indexByteOutsideQuotes with terminalHashIndex (quote- and paren-depth-aware) so terminal `#` is distinguished from inline `#(`. - Extract parseSelectorPart, parseInlineChildSelector, and matchingCloseParen for readable selector-part parsing. - Reject inline `#(...)` after a value spec, and error on unexpected trailing content after a value spec (previously silently ignored). - Document the inline form in README and add parse, parse-error, and Collect test coverage with golden fixtures. * refactor(value-extractor): unify terminal '#' into per-selector RequireChild Replace the top-level ValueExtractor.ChildSelectors field with a per-selector gate so the terminal '#' and inline '#(...)' forms share one code path. A terminal '#X' is now folded into a RequireChild chain on the last selector, exactly as if it were an inline '#(X)'. - BlockSelector.RequireChild becomes [][]BlockSelector: a list of independent descendant chains, all of which must match (conjunctive). A selector may carry any number of gates (multiple '#(...)' clauses and/or a trailing terminal '#'). - Remove the Collect-time post-filter; gating now happens uniformly in BlockSelector.Matches. - Fix a silent bug: when a terminal '#' appeared both in the selector chain and after the value spec, the second overwrote the first and one gate was dropped. Both are now accumulated and folded onto the last selector. - Error on a terminal '#' with no preceding parent selector. BREAKING CHANGE: removes the exported ValueExtractor.ChildSelectors field (present since v1.0.0). Consumers reading it must migrate to BlockSelector.RequireChild. Tests: add inline_child_two_gates and double_terminal_hash parse cases, TestCollectInlineChildTwoGates / TestCollectDoubleTerminalHash / TestCollectInlineChildNested behavioral tests, a terminal_hash_no_parent error case, and TestValueExtractorParseErrorMessages pinning the exact message of each child-selector guard. README documents the unified model and conjunctive multi-gate behavior.
support attributes+data, make commas optional in the value spec
PreviousNext