Run artifact

workspace/targets/commonmark/blueprint/FEATURE-Setext-Headings.md

FEATURE: Setext Headings

FieldValue
Version20261014 V1
DescriptionParse setext headings, including multiline content and the precedence and laziness exclusions.
Depends OnFEATURE-Block-Quotes.md
Providessetext heading block
Consumesparagraph block, thematic break block

Purpose

Implement the Setext headings section of the spec.

Rules

Reads

Writes

Programmatic Acceptance

The corpus section has examples that use lists, so it is gated in the lists story. The checks here are bounded.

=== AC setext-both-levels ===
Intent: Equals underlines give h1 and dash underlines give h2.

import subprocess

equals = subprocess.run(["./commonmark"], input="Foo bar\n=========\n", capture_output=True, text=True) dashes = subprocess.run(["./commonmark"], input="Foo bar\n---------\n", capture_output=True, text=True) print(equals.stdout) print(dashes.stdout) assert equals.returncode == 0 assert dashes.returncode == 0 assert equals.stdout.count("<h1>") == 1 assert dashes.stdout.count("<h2>") == 1 assert equals.stdout.count("<em>") == 1 === END AC setext-both-levels ===

=== AC setext-multiline-content ===
Intent: Several paragraph lines before the underline become one heading with no paragraph.

import subprocess

result = subprocess.run(["./commonmark"], input="Foo\nBar\n---\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<h2>") == 1 assert result.stdout.count("<p>") == 0 === END AC setext-multiline-content ===

=== AC setext-underline-beats-thematic-break ===
Intent: Dashes after paragraph text make a heading, not a thematic break.

import subprocess

result = subprocess.run(["./commonmark"], input="Foo\n---\nbar\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<h2>") == 1 assert result.stdout.count("<hr />") == 0 assert result.stdout.count("<p>") == 1 === END AC setext-underline-beats-thematic-break ===

=== AC setext-sequence-with-thematic-breaks ===
Intent: Dashes with no preceding paragraph are thematic breaks, mixed with two setext headings and a paragraph.

import subprocess

result = subprocess.run(["./commonmark"], input="---\nFoo\n---\nBar\n---\nBaz\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<hr />") == 1 assert result.stdout.count("<h2>") == 2 assert result.stdout.count("<p>") == 1 === END AC setext-sequence-with-thematic-breaks ===

=== AC setext-underline-limits ===
Intent: Four spaces of indentation or internal spaces disqualify the underline.

import subprocess

for source in ("Foo\n ---\n", "Foo\n= =\n"): result = subprocess.run(["./commonmark"], input=source, capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<h1>") == 0 assert result.stdout.count("<h2>") == 0 assert result.stdout.count("<p>") == 1 === END AC setext-underline-limits ===

=== AC setext-not-lazy-in-quote ===
Intent: An unmarked underline after a quote paragraph does not make a heading inside the quote.

import subprocess

result = subprocess.run(["./commonmark"], input="> foo\nbar\n===\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<h1>") == 0 assert result.stdout.count("<blockquote>") == 1 assert result.stdout.count("<p>") == 1 === END AC setext-not-lazy-in-quote ===

=== AC setext-quote-then-thematic-break ===
Intent: Dashes after a quote without a marker are a thematic break outside the quote.

import subprocess

result = subprocess.run(["./commonmark"], input="> Foo\n---\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<blockquote>") == 1 assert result.stdout.count("<hr />") == 1 assert result.stdout.count("<h2>") == 0 === END AC setext-quote-then-thematic-break ===

=== AC setext-empty-is-paragraph ===
Intent: An underline with no content line is not a heading.

import subprocess

result = subprocess.run(["./commonmark"], input="\n====\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<h1>") == 0 assert result.stdout.count("<p>") == 1 === END AC setext-empty-is-paragraph ===

User Acceptance

Guardrails