this post was submitted on 30 Nov 2025
-3 points (36.4% liked)
ShareGPT
88 readers
2 users here now
To share LLM text output that others might find interesting.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
what are the usual ways of using references in commonmark markdown?
Here is a summary of the usual ways of using references (reference-style links) in CommonMark (standard Markdown). This lets you separate link text from link destinations, making source text cleaner and easier to maintain.
🔹 Main reference-link syntax in CommonMark
Link reference definitions
You first define a “label → URL (and optional title)” somewhere in the document (before or after links that use it). The general form is:
:), then the URL (destination), optionally a title in quotes. (spec.commonmark.org)Using the references in link text
Once defined, you can use these references elsewhere as follows:
Full reference link:
This creates a link whose displayed text is “Link text” and which points to the URL defined under
my-label. (spec.commonmark.org)Collapsed reference link (shortcut for when displayed text equals the label):
This displays “my-label” and links to its definition. (spec.commonmark.org)
Shortcut reference link (simplest form, also when label = link text):
CommonMark treats this as a reference link — but only if there is a matching definition. Label matching is done on a normalized version (case-folded, internal whitespace collapsed). (spec.commonmark.org)
Precedence and corner cases
[text](URL "title")) take precedence over reference links. So if you write[foo](), even iffoohas a reference definition, that will be treated as empty inline link, not reference link. (spec.commonmark.org)✳️ Why / When It’s Useful
✅ Example of a full pattern
Here’s a small example combining definitions and use:
This will render two identical links (“Markdown documentation” and “CommonMark spec”) both pointing to the same URL, with title attribute “CommonMark — Specification.”