Repository navigation
feat(rules): add items rule to validate each list item - #102
Merged
Merged
Conversation
A list rule could require a list but not constrain what its items say. Add `items` to list rules, applying `required_text` and `forbidden_text` to every top-level item of a matching list. Items are matched against their raw Markdown, and one violation is reported per failing (item, pattern) pair at the item's position. The parser now records each list's items, replacing ItemCount with Items. The literal/regex matching shared by required_text and forbidden_text moves into a single helper. Based on the design in #89. Co-authored-by: sakanaka <[email protected]> Claude-Session: https://claude.ai/code/session_014K1p9VkeotiX1SR8pLWJSK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
itemsto list rules so a schema can constrain every top-level item of a list, not just require the list to exist:Supersedes #89, reworked on top of #100 and #101. Thanks to @kinchoKayaba for the original proposal and implementation.
Design
itemsreusesrequired_text/forbidden_text, with the same literal (substring) and{pattern: ...}(regex) forms, instead of a newitems_must_matchkey. This keeps the vocabulary users already know and leaves room for more per-item rules later.required_textentries are combined with AND, as in section-levelrequired_text. Go's regex engine has no lookahead, so AND cannot be expressed in a single pattern.**Card**keeps its asterisks. This matches how section-level text rules see content.typeare checked. Sub-lists are already excluded since fix(parser): count only top-level lists in list rules #100.Changes
schema.ListRule.Items(ListItemsRule);schema.jsonregeneratedparser.List.Items(ListItem{Text, Line, Column}) replacesItemCountinternal/rules/list.go: per-item checks andgeneratehintsinternal/rules/text_pattern.go: shared literal/regex matching forrequired_text,forbidden_text, anditemsTest plan
forbidden_text, nested items skipped,typerespected, generator hintsitemsloads without unknown-key warningsgo test ./...andgo vet ./...pass;examples/*and the README self-check pass