Metadata, containers and custom publishing rules

Extended Markdown profiles can store more than visible formatting. YAML metadata, identifiers, and attributes allow additional information; Divs and Spans supply generic containers. These can underpin an editorial authoring profile when its rules are explicitly defined.

The last two specimens in this chapter deliberately use custom Lua filters. They belong to this example project, not to a Markdown standard. Without the filters, neither an index nor an audience-reduced publication is generated. This distinguishes the ability to store information from an implemented function. S15, S16

Example 44: YAML metadata with lists and objects

Pandoc Markdown

A YAML block begins and ends with three hyphens here. It contains simple values and a list of author objects. Indentation belongs to the YAML structure. edition: "01" deliberately stores a string so that the leading zero is not treated as part of a number.

SOURCE

---
title: "Editorial Reference"
author:
  - name: "Alex Morgan"
    affiliation: "Northlight Publishing"
lang: en-GB
keywords: [publishing, markdown, quality]
edition: "01"
---

This document has structured metadata.

ACTUAL PROCESSOR OUTPUT

HTML output of YAML metadata with lists and objects

Pandoc reads these values into its metadata model. The specimen preview therefore shows a real JSON excerpt from that model rather than an invented title page. Which fields an HTML or Word template displays is a separate question. An arbitrary custom field is not automatically published, validated, or mapped to a corresponding domain-specific XML element.

Example 45: The simple Pandoc title block

Pandoc Markdown

Alongside YAML, Pandoc supports a simple title block using percent signs. The three lines represent title, authors, and date. Semicolons separate two authors here. This is convenient for small documents with limited metadata.

SOURCE

% Editorial Reference
% Alex Morgan; Jamie Lee
% 21 September 2026

This is a small reference publication.

ACTUAL PROCESSOR OUTPUT

HTML output of the simple title block using percent signs

The preview again shows the metadata actually parsed. YAML is more suitable for nested author information, several language editions, or editorial status fields. Both notations are extensions, not universal properties of files ending in .md. The filename extension alone does not identify the agreed metadata profile.

Example 46: Divs, spans and domain classes

Pandoc Markdown

Three colons with attributes open a Div container; a colon run without attributes closes it. The example Div contains a paragraph and a list. Inside the paragraph, a bracketed span identifies a smaller classified range.

SOURCE

::: {#review-note .note}
Review the [source identifier]{.term data-kind="identifier"}
before publication.

- Keep the identifier stable.
- Check the link target.
:::

RENDERED RESULT

HTML output of a Div container with classes

The identifier is a link target, .note and .term are classes, and data-kind is another attribute. The note's orange appearance comes from the supplied CSS. Pandoc does not thereby know which domain rules a note or identifier must satisfy. A profile can define those conventions and check them with a filter.

Example 47: Format-specific raw blocks

Pandoc Markdown

Raw attributes can bind content to an output format. The first block contains HTML, the second a LaTeX page break. Only the first raw block appears in the HTML preview. The ordinary paragraph survives independently.

SOURCE

```{=html}
<p class="web-only">Only the HTML edition contains this paragraph.</p>
```

```{=latex}
\newpage
```

This paragraph belongs to every edition.

RENDERED RESULT

HTML output of format-specific raw blocks

This is not a portable Markdown page break. The LaTeX command has no automatic counterpart in a DOCX writer. Mixed sources can accumulate so many output-specific cases that maintenance becomes difficult. A test report should consequently document deliberately omitted raw blocks as well as errors.

Example 48: Index entries implemented by a custom filter

Pandoc Markdown + index.lua

This example explicitly introduces a custom convention. Spans with the index class supply index terms. The included Lua filter collects and sorts them, then replaces the empty container with a linked index. The preview was generated using that exact filter.

SOURCE

A [publication]{.index term="Publication"} can have several editions.

The [source format]{.index term="Source format"} must be documented.

::: {#generated-index}
:::

RENDERED RESULT

HTML output of index entries implemented by a custom filter

Without the filter, no index is produced. Even with it, the result is only a simple alphabetical linked index, without printed page numbers, subentries, or "see also" relationships. The specimen distinguishes attributes that syntax can store from publishing functions that have actually been implemented. A comprehensive index model requires more than this demonstration.

Example 49: Audience variants using filter logic

Pandoc Markdown + audience.lua

Audience selection is another custom convention here. The audience metadata value determines which classified blocks the filter keeps. Public output contains the first message but not the internal ticket number. The build explicitly checks that the internal text is absent.

SOURCE

---
audience: public
---

::: {.audience only="public"}
The release is available to readers.
:::

::: {.audience only="internal"}
The internal review ticket is REF-42.
:::

RENDERED RESULT

HTML output of audience variants using filter logic

Hiding it with CSS would not be equivalent, because the text would remain in the file. This small demonstration profile is not a complete security design for confidential content either. Production distribution requires checks on references, metadata, attachments, and every alternative output for unintended disclosure.

The more classes, attributes, and filters a project requires, the more important profile documentation, version control, and tests become. A simple file format does not eliminate modeling work; it moves some of it into conventions and program code. That can be a reasonable choice, but it should be deliberate.

<< back                                                                                                             next >>