XML technologies / Markdown in publishing / Links, images and media

Links and images share a large part of their syntax in Markdown. The simplicity must not obscure the fact that the link target, visible link text, image caption and alternative text are different pieces of information. A production system must treat them separately when necessary.

The examples use local image and audio files from the package as well as illustrative web addresses. The local resources are reproducibly present. An automatic check verifies their existence and the internal jump targets. The accessibility of the illustrative external addresses, however, is not part of this test. S02, S07

Example 20: Inline links and reference links

CommonMark

An inline link consists of the visible link text in square brackets and the target in round brackets. An optional title follows in quotation marks. Reference links move the target and title to a separate definition. The text can thus access the same definition multiple times without repeating the URL.

SOURCE

Read the [manual](https://example.org/manual "Editorial manual").

Use [the same manual][guide] during editing.
Try [guide][] or the shortcut [guide].

[guide]: https://example.org/manual "Editorial manual"

RENDERED RESULT

HTML output of the inline link and reference links

The example shows the full, the collapsed and the shortcut form of a reference link. All four links receive the same target. The identifier guide is not an ID of a paragraph and not a literature record. A non-existent definition does not reliably produce an error; the syntax can remain as ordinary text.

Example 21: Automatic links and email addresses

GFM, formal profile

URLs and email addresses in angle brackets belong to the CommonMark core. The last line without brackets is recognized here as a link by the GFM profile. Exactly this difference is a small but easily testable dialect test.

SOURCE

<https://example.org/catalog>

<editor@example.org>

https://example.org/releases

RENDERED RESULT

HTML output with linked URLs and a linked email address

The email address becomes a mailto:-link. None of these conversions confirms that the target is reachable or that the address is correct. The example.org-addresses are illustrative test targets. In the production process, reachability, permitted protocols and, where applicable, external redirects should be checked separately.

Example 22: Stable internal references

Pandoc Markdown

The link to a fragment target uses the same link syntax as an external link. The target begins with #. Pandoc assigns the heading {#editorial-checklist} an explicit identifier. A changed heading text therefore does not have to change the address of the target.

SOURCE

# Editorial checklist {#editorial-checklist}

Check the references before release.

Return to the [editorial checklist](#editorial-checklist).

RENDERED RESULT

HTML output with an internal reference

The link syntax itself is widely usable; the explicit attribute syntax is Pandoc-specific here. IDs automatically generated from headings differ between platforms. A functioning jump is also not yet an automatically labelled reference such as "see chapter 7". The tests therefore check target resolution separately from numbering and link text.

Example 23: Image syntax and reference images

CommonMark

An exclamation mark before the link notation turns it into an image. The square brackets contain alternative text, the round brackets contain the image path and, if applicable, a title. The reference notation works in the same way as reference links. In the second line, the image is inside a paragraph.

SOURCE

![Orange sample cover](assets/cover.png "Reference edition")

The same asset: ![Orange sample cover][cover]

[cover]: assets/cover.png

RENDERED RESULT

HTML output of the reference images

A title is not a substitute for alternative text. Likewise, no image caption is automatically created in the CommonMark core. Relative paths must be resolved with the correct resource directory during the build. The enclosed PNG file therefore belongs to the package; a missing file must not be considered successfully embedded merely because a preview shows an image icon.

Example 24: Image caption, width and identifier

Pandoc Markdown

A standalone image reference can be treated by Pandoc with implicit_figures as a figure. The caption in square brackets becomes the image caption. The following attributes assign an identifier and a relative width. In the HTML output shown, figure, img and figcaption.

SOURCE

![A sample publication cover.](assets/cover.png){#cover-figure width=25%}

RENDERED RESULT

HTML output of the reference image with caption, identifier and relative width

The visible image title and the alternative text are technically different pieces of information, even if this simple mechanism uses the same source text. An editorial team with separate requirements needs a richer convention or a filter for this. The identifier alone also does not yet create an automatically numbered reference to the figure.

Example 25: Audio as an HTML extension with text alternative

CommonMark

There is no standalone Markdown syntax for audio in the CommonMark core. A genuine HTML element is therefore embedded here. The WAV file and a transcript are included in the package. The HTML preview shows the player; playback only occurs after a user action.

SOURCE

<audio controls="controls" src="assets/sample.wav">
  Your browser does not support audio playback.
</audio>

[Read the transcript](assets/transcript.txt).

RENDERED RESULT

HTML output with embedded audio file

A Word document or a printed PDF therefore does not receive a corresponding player. The separately written link to the transcript remains available as a portable alternative. The same fundamental problem applies to video. Platforms can also filter embedded HTML. Content, rights information, subtitles and media alternatives should therefore not be hidden exclusively in an HTML-Block be hidden.

Secure web publishing requires additional rules for URLs and embedded HTML. A parser is not a general security filter. For external or AI-generated content, permitted protocols, HTML elements and attributes should be defined. Images need reliable alternative texts, media need suitable text alternatives. These requirements do not disappear simply because the source file is called Markdown instead of HTML.

back to top