Run artifact

workspace/targets/commonmark/blueprint/FEATURE-Fenced-Code.md

FEATURE: Fenced Code

FieldValue
Version20261014 V1
DescriptionParse fenced code blocks delimited by backtick or tilde fences with info strings and indentation stripping.
Depends OnFEATURE-Indented-Code.md
Providesfenced code block
Consumesblock-type registry, shared unescape and entity helpers

Purpose

Implement the Fenced code blocks section of the spec.

Rules

Reads

Writes

Programmatic Acceptance

The corpus section examples use quotes, lists and setext headings, so it is gated in the lists story. The checks here are bounded.

=== AC fenced-backtick-and-tilde ===
Intent: Backtick and tilde fences each render one pre element containing the supplied body.

import subprocess

body = "some body text" for fence in ("`", "~~~"): source = fence + "\n" + body + "\n" + fence + "\n" result = subprocess.run(["./commonmark"], input=source, capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<pre>") == 1 assert body in result.stdout === END AC fenced-backtick-and-tilde ===

=== AC fenced-info-string-language-class ===
Intent: The first word of the info string becomes the language class.

import subprocess

language = "ruby" source = "" + language + " extra words\ncode\n\n" result = subprocess.run(["./commonmark"], input=source, capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert ('class="language-' + language + '"') in result.stdout === END AC fenced-info-string-language-class ===

=== AC fenced-closing-fence-rules ===
Intent: A fence of the other character, or a shorter fence, does not close the block.

import subprocess

other = "~~~" shorter = "" source = "`\naaa\n" + other + "\n" + shorter + "\n" result = subprocess.run(["./commonmark"], input=source, capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<pre>") == 1 assert other in result.stdout assert shorter in result.stdout === END AC fenced-closing-fence-rules ===

=== AC fenced-unclosed-runs-to-end ===
Intent: An unclosed fence consumes the rest of the document as code.

import subprocess

trailing = "still code" result = subprocess.run(["./commonmark"], input="`\nfirst\n\n" + trailing + "\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<pre>") == 1 assert result.stdout.count("<p>") == 0 assert trailing in result.stdout === END AC fenced-unclosed-runs-to-end ===

=== AC fenced-interrupts-paragraph ===
Intent: A fence interrupts a paragraph and text after it starts a new paragraph.

import subprocess

result = subprocess.run(["./commonmark"], input="foo\n\nbar\n\nbaz\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<pre>") == 1 assert result.stdout.count("<p>") == 2 === END AC fenced-interrupts-paragraph ===

=== AC fenced-two-backticks-not-a-fence ===
Intent: Two backticks do not open a fence; they form a code span instead.

import subprocess

result = subprocess.run(["./commonmark"], input="\nfoo\n\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<pre>") == 0 assert result.stdout.count("<code>") == 1 === END AC fenced-two-backticks-not-a-fence ===

=== AC fenced-indentation-stripped ===
Intent: Content indentation up to the fence indentation is removed, and unindented lines are kept.

import subprocess

result = subprocess.run(["./commonmark"], input=" \n aaa\naaa\n\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<pre>") == 1 assert result.stdout.count("aaa") == 2 assert result.stdout.count(" aaa") == 0 === END AC fenced-indentation-stripped ===

User Acceptance

Guardrails