Skip to content

LearnMD — Format Specification v0.4

Part of the LearnSpec suite. Draft based on v0.3.

Core principle

LearnMD is the educational content format of the LearnSpec suite. It covers instruction — explaining what to know — while QuizMD covers assessment. Together they form a complete teach → assess stack, in portable plain-text files.

A complete course — chapters, lessons, exercises, quizzes — can live in a single valid .learn.md file. The !import directive is a composition tool for reusability, not a prerequisite.

PrincipleDescription
Markdown-firstA .learn.md file is valid Markdown readable in any editor
File-nativeAll content lives in files — no database required
Git-nativeVersionable, diffable, and mergeable like code
AI-nativeGeneratable and consumable by LLMs without specific tooling
Progressively enrichedPlain text (Level 0) up through special fenced blocks (Level 2)
LearnSpec-interoperableNatively integrates with QuizMD, DiagramMD, MediaMD, and GlossaryMD

LearnMD inherits the universal frontmatter, directives, and validation rules defined in the Architecture Charter.

Format levels

LevelMechanismPurpose
0Plain .learn.md, native MarkdownMinimal content, readable everywhere
1YAML frontmatter + GFM calloutsMetadata, estimated time, language
2Special fenced blocks + directivesExamples, summaries, inline quizzes, imports

Each level is a strict superset of the previous one. A Level 0 file is valid at Level 1 and 2.

Document architecture

Three-tier hierarchy

document (.learn.md, minimal or no frontmatter)
└── module (## heading)
    └── lesson (### heading or file imported via !import)
  • Structure is strictly linear in v0.4 (no branching).
  • ```quiz blocks and !import, !ref, !checkpoint directives are usable at any level.
  • Images are referenced via ![alt](media:slug "fallback") (recommended) or ![alt](url) (direct).

Level 0 — Plain Markdown

Basic syntax

SyntaxMeaning
# TitleDocument title (inferred by the parser if absent from frontmatter)
## Module titleMain section heading
### Lesson titleSub-section heading
> textGeneric blockquote
!import ./file.learn.mdInclude another lesson file
!import ./file.quiz.mdEmbed an external QuizMD checkpoint
!ref ./file.diagram.mdDeclare a DiagramMD context (enables ```diagram ref:slug resolution)
!ref ./file.media.mdDeclare a MediaMD context (enables media:slug resolution)
!ref ./file.glossary.mdDeclare a GlossaryMD context (enables term highlighting)
```diagram ref:slugRender a named diagram from a !ref-ed DiagramMD file
!checkpoint id:slugMark a learner progress checkpoint
$...$Inline LaTeX math formula
$$...$$Block (display) LaTeX math formula
![alt](media:slug "fallback-url")Image via MediaMD with fallback for standard readers
![alt](url)Direct image (URL)

Minimal example

markdown
# Introduction to Python

!ref ./glossary-python.glossary.md

## Module 1 — Variables

A **variable** is a named reference to a value in memory.

```python
age = 25
name = "Alice"
```

!checkpoint id:module-1-done label:"Module 1 complete"

## Module 2 — Conditions

An `if` statement runs code only when a condition is true.

Level 1 — YAML frontmatter

A YAML block at the top of the .learn.md file, between two --- lines.

yaml
---
title: Python — Variables      # optional — inferred from the first # H1 if absent
lang: en                       # REQUIRED — BCP-47 code (en, fr, en-US, …)
description: "Names, assignment, and basic types in Python — for learners with no prior programming experience."
                               # optional — short summary for catalogues, previews, and meta tags
estimated_time: 15min          # optional — free-form duration string
tags: [python, variables]      # optional — list of strings
author: Jane Smith             # optional — string or {name, email, url}
spec_version: "0.4"            # optional — LearnMD spec version this file targets
created: 2026-05-10            # optional — ISO 8601
updated: 2026-05-10            # optional — ISO 8601
license: CC-BY-4.0             # optional — SPDX identifier or "custom"
---

Field reference

FieldRequiredTypeDescription
titleNostringOverrides the first # H1. Inferred from H1 if absent.
langYesBCP-47Language code: en, fr, en-US, etc.
descriptionNostringShort plain-text summary (typically 1–3 sentences) — used for catalogues, link previews, and <meta name="description">. Distinct from title and from the body content.
estimated_timeNostringFree-form estimated reading/study time: 15min, 1h30, 2h
tagsNostring[]Thematic tags
authorNostring or objectAuthor name, or {name, email, url}
spec_versionNostringLearnMD spec version this file targets (e.g. "0.4")
createdNodateCreation date, ISO 8601
updatedNodateLast update date, ISO 8601
licenseNostringSPDX identifier (e.g. CC-BY-4.0) or custom

GFM callouts

Callouts use GitHub Flavored Markdown syntax and are rendered with visual emphasis by compatible players.

Supported everywhere (GitHub, Obsidian, LearnSpec players):

SyntaxSemanticTypical use
> [!note]NoteSupplementary information
> [!tip]TipBest practice, shortcut, helpful advice
> [!warning]WarningCommon pitfall, frequent mistake
> [!important]ImportantCritical point to remember
> [!caution]CautionRisk of error or data loss

Extended callouts (degrade gracefully to a blockquote on GitHub):

SyntaxSemanticTypical use
> [!summary]SummaryKey takeaways at the end of a lesson
> [!example]ExampleNon-code illustrative example
> [!objectives]Learning ObjectivesWhat the learner will be able to do — place at top

Level 2 — Special fenced blocks and directives

Composition directives

!import <path>

Includes content from another file at the current position. The file type is detected from the extension:

ExtensionBehaviour
.learn.mdLesson content inserted inline (frontmatter ignored)
.quiz.mdRendered as an interactive QuizMD checkpoint

DiagramMD files (.diagram.md) are not consumed via !import — they are leaf catalogues declared with !ref and addressed by slug. See !ref below.

markdown
!import ./03-conditions.learn.md
!import ./check-variables.quiz.md
  • Imports are recursive (an imported file may itself contain !import directives).
  • Circular imports are silently skipped.
  • Local paths or external URLs accepted — see the Architecture Charter.

!ref <path>

Declares a context file without including its content inline. Produces no visible render — it establishes a context the player uses in the background.

ExtensionBehaviour
.media.mdEnables media:slug reference resolution
.glossary.mdEnables defined-term highlighting
markdown
!ref ./media-python.media.md
!ref ./glossary-python.glossary.md
!ref https://github.com/example/commons/blob/main/glossaries/en/computing.glossary.md

Multiple !ref directives may coexist in the same document.

!checkpoint id:slug [label:"..."] [type:...] [badge:...]

Marks a named progress point in the lesson.

markdown
!checkpoint id:module-1-done label:"Module 1 complete"
!checkpoint id:module-variables-done label:"Variables mastered" badge:./badge-variables.badge.md
AttributeRequiredDefaultDescription
idYesUnique identifier within the document
labelNo"Checkpoint"Display text shown to the learner
typeNomilestonemilestone / read / exercise-complete
badgeNoPath to a BadgeMD file awarded when this checkpoint is reached

Rules:

  • id values must be unique within a document.
  • When a !import ./quiz.quiz.md is present, the quiz itself acts as a natural checkpoint — an additional !checkpoint at the same position is redundant.

Checkpoint JSON (parser output)

json
{
  "checkpoints": [
    { "id": "module-1-done", "label": "Module 1 complete", "type": "milestone", "position": 42 },
    { "id": "module-2-done", "label": "Module 2 complete", "type": "milestone", "position": 87 }
  ]
}

Inline quiz checkpoint

Embeds a single question using QuizMD Level 0 syntax directly in the lesson. The QuizMD frontmatter (global configuration — scoring, reveal, feedback_mode) is not applicable inline. All QuizMD Level 0 question types are supported: mcq, multi, open, tf, match, order.

markdown
```quiz
? Which operator assigns a value in Python?
- [x] =
- [ ] ==
- [ ] :=
```
AttributeDefaultDescription
scored:falseYes (default)Practice mode — immediate feedback, no score recorded
scored:trueScored checkpoint — contributes to lesson score

Inline quiz vs external file:

NeedSyntax
Single simple questionInline ```quiz block
Multiple questions, advanced scoring, or shared config!import ./file.quiz.md

Fenced callout blocks

Level 2 alternatives to GFM callouts. Support richer content (multi-paragraph, nested lists, syntax-highlighted code).

LanguageIconLabelTypical use
```note📝NoteSupplementary information
```tip💡TipBest practice or helpful advice
```warning⚠️WarningCommon pitfall, frequent mistake
```importantImportantCritical point to remember
```caution🔴CautionRisk of error or data loss
```summarySummaryKey takeaways at the end of a lesson
```example🔍ExampleIllustrative example
```objectives🎯Learning ObjectivesWhat the learner will achieve — place at top

Optional title attribute:

markdown
```example title:"Token prediction"
Context: "The capital of France is"
Most likely token: " Paris"
```

Optional code language — place before title: to enable syntax highlighting:

markdown
```example python title:"Assigning and reassigning a variable"
score = 0
print(score)   # → 0

score = 42
print(score)   # → 42
```

Math support

LearnMD uses LaTeX formulas rendered via KaTeX. Math is auto-detected — no frontmatter flag is required.

FormSyntaxRendering
Inline$E = mc^2$Embedded in the line of text
Block (display)$$\int_0^\infty e^{-x}\,dx = 1$$Centred on its own line

Diagram support

LearnMD supports all diagram block types defined in the DiagramMD spec. Inline diagrams use DiagramMD Level 0 fenced block syntax with optional Level 2 attributes (caption, width, alt). The DiagramMD frontmatter (Level 1) is not applicable inline.

markdown
```mermaid caption:"System architecture" width:80% alt:"Client-API-DB diagram"
flowchart LR
    Client --> API --> DB
```
markdown
```abc play
X:1
T:Main Theme
K:C
|: G2 AB c2 BA | G4 E4 :|
```

Supported types, shared attributes (caption, width, alt), and AI authoring recommendations are documented in the DiagramMD spec.

For diagrams reused across multiple lessons, gather them in a .diagram.md catalogue declared via !ref ./file.diagram.md and reference each one inline with:

markdown
```diagram ref:auth-flow
```

Media references

Images are referenced via two mechanisms.

Requires a !ref to a MediaMD file at the top of the document. Enables automatic licence and attribution resolution.

markdown
!ref ./media-biology.media.md

![Chloroplast diagram](media:chloroplast "https://upload.wikimedia.org/.../chloroplast.svg")
  • media:chloroplast: slug resolved via the MediaMD → full-resolution image + licence metadata.
  • "https://...": fallback URL — displayed in standard readers without LearnSpec.

Direct (URL)

markdown
![Chloroplast diagram](https://example.com/chloroplast.svg)

Syntax reference

ElementSyntaxLevel
Document title# Title0
Module heading## Module title0
Lesson heading### Lesson title0
Generic blockquote> text0
Import lesson!import ./file.learn.md0
Embed quiz!import ./file.quiz.md0
Declare DiagramMD!ref ./file.diagram.md0
Reference a diagram```diagram ref:slug0
Declare MediaMD!ref ./file.media.md0
Declare GlossaryMD!ref ./file.glossary.md0
Progress checkpoint!checkpoint id:slug [label:"..."] [type:...] [badge:...]0
Inline math$formula$0
Block math$$formula$$0
Image via MediaMD![alt](media:slug "fallback")0
Direct image![alt](url)0
Diagram block```{type} [caption:"..."] [width:...] [alt:"..."]0
Frontmatter--- YAML ---1
Note callout> [!note]1
Tip callout> [!tip]1
Warning callout> [!warning]1
Important callout> [!important]1
Summary callout> [!summary]1
Example callout> [!example]1
Objectives callout> [!objectives]1
Inline quiz```quiz2
Scored inline quiz```quiz scored:true2
Note callout (fenced)```note2
Summary callout (fenced)```summary2
Example callout (fenced)```example [lang] [title:"..."]2
Objectives callout (fenced)```objectives2

Validation

Lenient mode (default)

ConditionLevel
lang absent from frontmatterWarning
Title absent (no H1 and no frontmatter title)Warning
Unclosed fenced blockError
Inline quiz block with no ? lineError
!checkpoint missing required id attributeError
Duplicate !checkpoint id within a documentError
!import pointing to a missing fileWarning
!ref pointing to a missing fileWarning
media:slug without a matching !ref MediaMDWarning
media:slug without a fallback URLWarning

Strict mode (--strict)

ConditionLevel
lang absentError
Title absentError
All lenient-mode errorsError
!ref pointing to a missing fileError
media:slug without a fallback URLError

Strict mode is recommended for CI pipelines and production publishing. Lenient mode is appropriate during authoring.

Changes from v0.3

ElementChange
Hierarchypath renamed to document (avoids confusion with TrackMD)
Principles"QuizMD-interoperable" → "LearnSpec-interoperable"
!refNew directive — declares DiagramMD, MediaMD and GlossaryMD contexts
Diagram referenceNew ```diagram ref:slug block — resolves a named diagram from a !ref-ed DiagramMD
ImagesNew media:slug syntax via MediaMD
FrontmatterAdded created, updated, license (universal LearnSpec fields)
DiagramsMermaid and ABC sections simplified — delegate to DiagramMD spec

Released under the MIT License.