=== BEGIN ARTIFACT FEATURE-Lists.md === # FEATURE: Lists | Field | Value | |-------------|-------| | Version | 20261014 V1 | | Description | Group list items into lists, compute tight and loose rendering, and gate the block-structure corpus sections. | | Depends On | FEATURE-List-Items.md | | Provides | list container, tight/loose computation | | Consumes | list item container | ## Questions - None. ## Purpose Implement the Lists section of the spec, and gate the block-structure sections whose examples need lists. ## Rules - Consecutive items of the same type form one list. Two items are of the same type if both are bullets with the same character, or both are ordered with the same delimiter. Changing the bullet character or the ordered delimiter starts a new list. - The start number of an ordered list is that of its first item. The `start` attribute is emitted only when it is not 1. - Items may be separated by any number of blank lines. Items need not be indented identically, as long as none is indented enough to be inside the previous item. - A list can interrupt a paragraph; an ordered list does so only if it starts at 1. - A list is loose if any two of its items are separated by a blank line, or if any item directly contains two block children with a blank line between them. Otherwise it is tight. Blank lines inside fenced code, inside a nested list's own children, or inside a block quote do not make the outer list loose. Link reference definitions do not count as blocks for this purpose. - In a tight list the paragraphs of the items render without `

` tags. In a loose list they render with them. Nested lists decide their own tightness. ## Reads - List item nodes from the block tree. ## Writes - List nodes and the tight flag in the block tree. ## Programmatic Acceptance === AC lists-corpus-sections === Intent: The Lists, List items, Block quotes, Thematic breaks, ATX headings, Setext headings, Indented code blocks, Fenced code blocks and Precedence conformance sections (roughly 300 cases) pass in full. Suite: scoped Probe: --dump-tests Probe Count: lines import os import subprocess import sys result = subprocess.run( [ sys.executable, "sources/spec_tests.py", "--program", os.getcwd() + "/commonmark", "--spec", "sources/spec.txt", "--pattern", "^Lists$|^List items$|^Block quotes$|^Thematic breaks$|^ATX headings$|^Setext headings$|^Indented code blocks$|^Fenced code blocks$|^Precedence$", ], capture_output=True, text=True, env={**os.environ}, ) print(result.stdout) print(result.stderr, file=sys.stderr) assert result.returncode == 0 === END AC lists-corpus-sections === === AC lists-changing-marker-starts-new-list === Intent: Changing the bullet character or ordered delimiter starts a new list. import subprocess bullets = subprocess.run(["./commonmark"], input="- foo\n- bar\n+ baz\n", capture_output=True, text=True) ordered = subprocess.run(["./commonmark"], input="1. foo\n2. bar\n3) baz\n", capture_output=True, text=True) print(bullets.stdout) print(ordered.stdout) assert bullets.returncode == 0 assert ordered.returncode == 0 assert bullets.stdout.count("