Run artifact

workspace/targets/commonmark/blueprint/FEATURE-Links.md

FEATURE: Links

FieldValue
Version20261014 V1
DescriptionImplement the look-for-link-or-image procedure and the inline, full, collapsed and shortcut link forms with the destination and title grammar.
Depends OnFEATURE-Emphasis.md, FEATURE-Link-Reference-Definitions.md
Provideslook_for_link_or_image procedure, link destination and title grammar
Consumesdelimiter stack, process_emphasis procedure, reference map, normalize_label

Purpose

Implement the Links section of the spec following the Appendix "look for link or image" procedure. The ![ machinery is shared with images; image rendering belongs to the images story.

Procedure

Grammar

Reads

Writes

Programmatic Acceptance

The Links corpus section includes image examples, so it is gated in the images story. The checks here are bounded.

=== AC links-inline-destination-and-title ===
Intent: An inline link renders one a element carrying the supplied destination, title and text.

import subprocess

text = "label" dest = "/uri" title = "the title" source = "[" + text + "](" + dest + ' "' + title + '")\n' result = subprocess.run(["./commonmark"], input=source, capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<a ") == 1 assert ('href="' + dest + '"') in result.stdout assert ('title="' + title + '"') in result.stdout assert (">" + text + "</a>") in result.stdout === END AC links-inline-destination-and-title ===

=== AC links-reference-forms ===
Intent: Full, collapsed and shortcut references each resolve against a definition and render one a element.

import subprocess

definition = "\n\n[foo]: /url\n" for use in ("[text][foo]", "[foo][]", "[foo]"): result = subprocess.run(["./commonmark"], input=use + definition, capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<a ") == 1 === END AC links-reference-forms ===

=== AC links-reference-case-insensitive ===
Intent: Label matching ignores case.

import subprocess

result = subprocess.run(["./commonmark"], input="[FOO]\n\n[foo]: /url\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<a ") == 1 === END AC links-reference-case-insensitive ===

=== AC links-undefined-reference-literal ===
Intent: A shortcut reference with no definition stays literal text.

import subprocess

result = subprocess.run(["./commonmark"], input="[nothing defined]\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<a ") == 0 === END AC links-undefined-reference-literal ===

=== AC links-no-nested-links ===
Intent: A link inside link text wins and the outer brackets stay literal, so only one a element appears.

import subprocess

result = subprocess.run(["./commonmark"], input="foo [bar](/uri)\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<a ") == 1 === END AC links-no-nested-links ===

=== AC links-space-before-parenthesis ===
Intent: Whitespace between link text and the parenthesis prevents an inline link.

import subprocess

result = subprocess.run(["./commonmark"], input="[link] (/uri)\n", capture_output=True, text=True) print(result.stdout) assert result.returncode == 0 assert result.stdout.count("<a ") == 0 === END AC links-space-before-parenthesis ===

User Acceptance

Guardrails