A Markdown file does not say which dialect it is written in. This page covers the versions there are, the five extensions GitHub Flavored Markdown adds to CommonMark (sections 4.10, 5.3, 6.5, 6.9 and 6.11 of that specification), and two common additions that no specification defines.
Versions
| Version | Date | What it is |
|---|---|---|
| Markdown | 2004 | John Gruber’s syntax description and Perl script, with Aaron Swartz. It left many cases undefined, and implementations disagreed. |
| CommonMark 0.31.2 | January 2024 | A complete, unambiguous specification of the core syntax, with a test suite of examples. The basis of the pages on this site. |
| GitHub Flavored Markdown 0.29-gfm | April 2019 | CommonMark (at version 0.29) with five extensions, which GitHub uses for its comments and files. |
Most other Markdown dialects are CommonMark or the original syntax with extensions of their own. The two tables below give the rules in which the other listed versions differ from CommonMark 0.31.2, which the other pages on this site describe.
GFM 0.29 core compared with CommonMark 0.31.2
GFM is based on an earlier version of CommonMark, so apart from its five extensions its core differs in these places:
| Rule | GFM 0.29 | CommonMark 0.31.2 |
|---|---|---|
| Unicode punctuation (for emphasis flanking) | Categories Pc, Pd, Pe, Pf, Pi, Po and Ps only | Any character in category P or S, so symbols count too |
| HTML comment (raw HTML) | <!--, text, -->; the text may not start with > or ->, end with -, or contain -- | <!-- to the first -->, and also <!--> and <!---> |
| Declaration (raw HTML) | <!, one or more uppercase letters, white space, then anything up to > | <!, an ASCII letter of either case, then anything up to > |
| HTML block type 1 | script, pre and style | Also textarea |
| HTML block type 4 | <! and an uppercase letter | <! and a letter of either case |
| HTML block type 6 names | Includes source; no search | Includes search; no source |
| HTML block type 7 | Any tag except script, style and pre | Any tag except script, style, pre and textarea |
Markdown 2004 compared with CommonMark
John Gruber’s syntax description is superseded by CommonMark for most tools, and leaves many cases open. Where it does state a rule, these are the ones that differ:
| Rule | Markdown 2004 | CommonMark 0.31.2 |
|---|---|---|
| Backslash escapes | 16 characters only: \ ` * _ { } [ ] ( ) # + - . ! | Every ASCII punctuation character |
| Ordered list numbers | Have no effect on the output, so a list always starts at 1 | The first item’s number is the list’s start number |
| Block-level HTML | Must have blank lines around it, and its start and end tags must not be indented; Markdown is not read inside it | Seven kinds of HTML block with their own start and end conditions; no blank line is needed before one, and types 6 and 7 end at a blank line, after which Markdown is read again |
| Link reference definitions | The URL may be in angle brackets and the title on the next line, in double or single quotes or parentheses (Markdown.pl 1.0.1 has a known bug with single quotes) | The same forms, all of them working; a definition may also run over several lines |
& and < | Escaped automatically unless part of an entity or an HTML tag | The same in effect, given by the rules for references and raw HTML |
| Line breaks | Two or more spaces at the end of a line make <br /> | The same, and a backslash at the end of a line too |
| Code indentation | At least 4 spaces or 1 tab | 4 columns, with tabs counted to a tab stop of 4 |
The media type is text/markdown, registered by
RFC 7763. Its charset
parameter is required, and an optional variant parameter names the
dialect, using values listed in RFC 7764.
4.10 Tables (GFM)
A table is a leaf block: a header row, a delimiter row and zero or more data rows. Each row is split into cells by unescaped pipes. Leading and trailing pipes are optional, and spaces around a cell’s content are removed. Block-level elements cannot go in a table; its cells hold inlines only.
The delimiter row holds only hyphens, with optional colons at either end of a cell,
and sets each column’s alignment: :-- left, :-: centre,
--: right. Its number of cells must match the header row’s, or the lines
are not a table at all.
| abc | defghi |
:-: | -----------:
bar | baz
A data row with fewer cells than the header is filled out with empty cells, and one
with more cells has the excess ignored. A pipe inside a cell, even in a code span, must
be escaped as \|. The table ends at the first blank line or the start of
another block-level structure, which means an unindented line of text that begins
no other block is taken as another row.
5.3 Task list items (GFM)
A list item whose first block is a paragraph beginning with a task list item
marker: optional spaces, a left bracket, a whitespace character, or
x or X, and a right bracket, then white space before the rest of the text. The item is
shown with a checkbox, ticked for x.
- [ ] to do
- [x] done
- [ ] nested
6.5 Strikethrough (GFM)
Text wrapped in a matching pair of one or two tildes, using the same flanking rules as
* in emphasis. A run of three or
more tildes does not make a strikethrough. The spans must not contain a blank line, since
blocks are settled first.
6.9 Autolinks, extended (GFM)
Some links are recognised with no angle brackets. They can begin only at the start of a
line, after white space, or after *, _, ~ or
(.
| Kind | Recognised when | Link goes to |
|---|---|---|
| www | www. then a valid domain | http:// and the text |
| URL | http:// or https://, then a valid domain | The text |
Letters, digits and . - _ +, then @, then letters, digits and . - _, with at least one period; the last character may not be - or _ | mailto: and the text | |
| Protocol | mailto: or xmpp: followed by an e-mail address; xmpp: may also have a / and a resource after it | The text |
A valid domain is segments of letters, digits, underscores and hyphens
separated by periods, with at least one period, and with no underscores in the last two
segments. After the domain, a link continues to the next white space or
<. Then:
- Trailing
?,!,.,,,:,*,_and~are not part of the link, though they may appear inside it. - If it ends in
), and has more closing than opening parentheses, the extra closing ones are left out. - If it ends in
;and looks like an entity reference, the reference is left out.
6.11 Disallowed raw HTML (GFM)
When HTML is written out, nine tags are made harmless by replacing the leading
< with <, because they are unusual and affect how the
page around them is shown: title, textarea, style,
xmp, iframe, noembed, noframes,
script and plaintext. Other HTML passes through unchanged.
Footnotes (not specified)
GitHub and other tools support footnotes, though neither CommonMark nor the GFM
specification defines them. A reference is [^label], and the definition is
[^label]: at the start of a line, followed by its text, which may continue
on following indented lines. Footnotes are numbered in the order they are first
referenced and shown at the end of the document. A reference with no definition is
plain text.
Front matter (not specified)
Many site generators and tools read metadata from a block at the top of the file,
between a line of --- and another of ---, usually written in
YAML. It is no part of any Markdown specification: to CommonMark, the same text is a
thematic break, then a heading or paragraph. A file with a real first thematic
break is therefore ambiguous, and tools disagree.
---
title: Packing list
draft: true
---
Diagrams in fenced code blocks (not specified)
Neither CommonMark nor GFM gives a fenced code block any meaning beyond its info string, the word after the opening fence. Many Markdown tools draw a diagram when that word names a diagram language. The viewer does so for the languages below, drawing the block as an SVG picture in the rendered document; a block that cannot be drawn stays as its text, with the reason above it. Nothing is fetched from the network to draw one.
nomnoml
Fence word nomnoml (also noml). nomnoml
draws UML-style diagrams from text that looks like the picture: a node is
[name], a node may hold compartments separated by |, and a
line of nodes joined by an association is an arrow.
- Classifiers:
[<type> name]where type isabstract,instance,reference,note,package,frame,database,pipe,start,end,state,choice,sync,input,lollipop,sender,socket,receiver,transceiver,actor,usecase,label,hiddenortable; no type is a class. Attributes follow the type, as in[<actor id=a> User], so two nodes may share a name. - Associations:
--><->(association),--><-->(dependency),-:><:-(generalization),--:><:--(implementation),+-+->(composition),o-o->(aggregation),-o)o<-)->o(ball and socket),--(note) and-/-(hidden). Text before and after the arrow labels its two ends. - Directives (a line starting with
#):direction(down or right),lineWidth,fill(colours separated by;),stroke,font,fontSize,leading,padding,spacing,gutter,edges(rounded or hard),edgeMargin,ranker,acyclicer,gravity,arrowSize,bendSize,fillArrows,background,zoomandtitle. - Styles:
#.name: fill=#8f8 stroke=#333 dashed empty visual=ellipse title=bold,italic body=center direction=rightdefines a classifier used as[<name> text];visualis any shape of the classifier list plusclass,ellipse,noneandrhomb. - Text:
//at the start of a line is a comment;\[ \] \| \;write the characters themselves,\nbreaks a line, and a;or a new line ends a statement.
#direction: right
[<abstract> Component||+ operation()]
[Decorator|- next: Component] decorates --> [Component]
[Component] <:- [ConcreteComponent]
Not covered: the #import: directive, which reads another file, is ignored, since
a dropped document has no other files to read.
Markmap
Fence word markmap (also mindmap-md). Markmap
draws a Markdown outline as a mind map: each heading and each list item is a node, and
nesting makes the branches. The map is live: clicking the small circle at a node folds or
unfolds its branch, dragging moves the map, Ctrl with the wheel zooms, and the
buttons Fit, Expand all and Collapse reset the view.
- Structure: headings
#to######and bullet or numbered lists nest to any depth; a list may sit under a heading. - Inline:
**bold**,*italic*,`code`,~~strike~~,==mark==,++inserted++,~sub~,^sup^, links (a web or mail address) and images. An image is drawn only from adata:image/…address; any other shows its alt text. In Markdown syntax only PNG, JPEG, GIF and WebP data addresses are accepted; an SVG one needs an HTML<img>. - Checkboxes:
- [x]and- [ ]. - Maths:
$…$inline and$$…$$as a block, drawn with KaTeX (supplied with the viewer, not fetched). - Blocks in a node: fenced code (plain, not coloured) and tables, indented under a list item.
- Folding:
<!-- markmap: fold -->after a heading folds that node and<!-- markmap: foldAll -->folds it with everything below. - Front matter (a
markmap:block between---lines):colorFreezeLevel,maxWidth,initialExpandLevel,color(a colour or a list),lineWidth,duration,zoom,pan,autoFit,fitRatio,maxInitialScale,nodeMinHeight,spacingHorizontal,spacingVertical,paddingXandtoggleRecursively;titleis shown above the map. Wheel panning is off unlesspan: true, so the wheel keeps scrolling the page.
---
title: Formats
markmap:
colorFreezeLevel: 2
---
# Files
## Text
- Markdown
- JSON
## Images
- [x] PNG
- [ ] BMP
Not covered: extraJs and extraCss in the front matter are ignored, since they
name scripts and style sheets to load; a link or image at an outside address is not loaded;
and code inside a node is not coloured, because the highlighter the library would fetch is not available.
D2
Fence word d2 (also d2lang). D2
is a declarative diagram language: a line naming two shapes joined by an arrow is a connection, and
braces nest shapes inside one another. The viewer runs D2's own compiler (the program compiled to
WebAssembly, supplied with the viewer and run in a worker), so every feature of the language that
needs no other file works. The first D2 block of a document takes a few seconds, while the 22 MB
program starts; later ones are quick.
- Shapes (
shape:):rectangle,square,page,parallelogram,document,cylinder,queue,package,step,callout,stored_data,person,diamond,oval,circle,hexagon,cloud,text,code,class,sql_table,imageandsequence_diagram. - Connections:
->,<-,<->and--, chained asa -> b -> c, with a label after a colon. Arrowheads (source-arrowhead,target-arrowhead):triangle,arrow,diamond,circle,box,cf-one,cf-many,cf-one-required,cf-many-requiredand the filled forms. - Containers: shapes nested in braces or written as
a.b.c;_names the parent;nearpins a shape to the edge of the diagram;directionisup,down,leftorright, also inside a container;grid-rows,grid-columns,grid-gapmake a grid. - Labels: plain text, a
|mdblock (Markdown), a|latexblock (maths) or a code block such as|go; use||md…||when the text holds a line that is just|. - Style (
style.):fill,fill-pattern,stroke,stroke-width,stroke-dash,opacity,shadow,3d,multiple,border-radius,double-border,font,font-size,font-color,bold,italic,underline,text-transformandanimated. - Icons:
icon:is drawn only when it is adata:image/…address; an address on the web is removed, never loaded.linkandtooltipwork. - Reuse:
classes,varswith${name}substitution, and globs (*.style.fill,(* -> *)[*]). - Boards:
layers,scenariosandstepsare drawn as extra boards; the document's own board is shown first, and a Board list above the picture switches to the others. - Configuration (
vars: { d2-config: { … } }):theme-id,dark-theme-id,sketch(hand-drawn look),pad,centerandlayout-engine, which isdagre(the default) orelk.
direction: right
server: Web server { shape: package }
db: Orders { shape: cylinder }
server -> db: reads and writes
db.style.fill: "#cfe8ff"
Not covered: @import and spread imports read other files, which a dropped document does not
have, so such a block shows D2's error; the TALA layout engine is a separate commercial program and
is not part of the viewer; an icon or image at a web address is not loaded; and a
document with several boards is not packed into one animated picture, each board is drawn on its own.
ditaa
Fence word ditaa. ditaa
(DIagrams Through Ascii Art) turns boxes and lines drawn with text characters into a proper diagram.
The viewer has its own renderer of ditaa's documented syntax, so no Java is involved and the
result is an SVG picture.
- Shapes: a closed outline of
+,-and|is a box, and shapes nest. Two boxes that share an edge are drawn a little apart./and\at a corner round it.-and|that bound nothing are plain lines. - Arrows and markers:
><^vat the end of a line are arrowheads, and*on a line is a small circle (the point marker). - Dashed lines: one
=(horizontal) or:(vertical) makes the whole line dashed, up to the next junction; a shape with one in its outline is dashed all round. - Colour:
cREDcGREcBLUcPNKcBLKcYEL, orcand three hex digits (c33F), inside a shape fills it; text on a dark fill turns white. - Tags inside a shape change its form:
{d}document,{s}storage,{io}input/output,{c}decision,{mo}manual operation,{tr}trapezoid,{o}ellipse. - Text: keeps its place in the grid;
o text(a space,o, a space) is a bullet point. - Options on a first line of the block, as
ditaa -S -ror@startditaa(--no-shadows, --scale=1.5):-Eno separation of shared edges,-Sno shadows,-rround every corner,-s nscale,-b hexbackground (six or eight digits),-Ttransparent,-Wfixed slope for slanted shapes,-t ntab width,-Ano anti-aliasing,-ddebug grid.
+--------+ +-------+ +-------+
| | --+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | |
| {d}| | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+-------------------------+
Not covered: custom shapes loaded from a shape configuration file ([name] tags), the
HTML mode, and the diagonal use of / and \ as lines (they round corners
only); the command-line options that name files or encodings are accepted and ignored.
blockdiag, seqdiag, actdiag, nwdiag, rackdiag, packetdiag
Fence words blockdiag, seqdiag, actdiag, nwdiag,
rackdiag and packetdiag. Takeshi Komiya's
blockdiag family
(Apache-2.0) draws diagrams from a small DOT-like language: diagram { ... } holding nodes,
edges (A -> B), groups and attributes. The viewer has a JavaScript port of the layout and drawing,
so no Python runs and the result is an SVG picture. Text is measured with the browser's own sans-serif font.
- blockdiag: nodes in a grid by rank; shapes
box,roundedbox,diamond,minidiamond,ellipse,circle,square,note,mail,cloud,actor,dots,textbox,none,beginpoint,endpointandflowchart.condition,.database,.input,.loopin,.loopout,.terminator(shape_namespace = flowchartshortens them). Edges-><-<->--and the crow's-foot forms-<>->-<, withlabel,style(dotted, dashed, none, or numbers such as"4,2"),color,textcolor,thick,folded,hstyle. Node attributeslabel,color,linecolor,textcolor,fontsize,width,height,numbered,stacked,style,rotate,label_orientation,href,icon,background;groupblocks (shape = linefor an outline);classandplugin attributes/autoclass; diagram attributesorientation,node_width,span_height,default_*,shadow_style,edge_layout = flowchart. - seqdiag: edges
->-->->><-=>,return,note/leftnote,diagonal,failed, self calls, edge blocks,===dividers and...delays,group,altandloopblocks, activations,autonumber,edge_length. - actdiag:
laneblocks and declarations, portrait or landscape. - nwdiag:
networkblocks,address,group, peer linksa -- b,external_connector = none. - rackdiag:
rackblocks, numbered (1: name) and bulleted items,2Uheights,1.5Aand3kgattributes,ascending. - packetdiag: fields
0-15: name,colwidth,scale_direction,scale_interval,len,height; long fields split across rows.
blockdiag {
A -> B -> C;
A -> D [style = dashed, label = "later"];
group { label = "Group"; B; C; }
D [shape = cloud];
}
Not covered: images at a file path or web address (an icon or background is read only
as a data: address); fonts other than the browser's sans-serif, so text widths and wrapping differ a
little from the Python program; the route statement and other plugins of the family; the
separate-image output mode and the description table of the Sphinx extension.
TikZ and PGF
Fence words tikz, latex-tikz and pgf. TikZ/PGF
is the drawing language of LaTeX. The viewer does not imitate it: it runs TeX itself (the
web2js build of TeX, as WebAssembly, with
LaTeX and TikZ already loaded, the approach of TikZJax)
in a background worker, reads the DVI file TeX writes, and draws it as one SVG picture in which every
letter is a path, so the picture needs no font. The first TikZ block of a session fetches TeX (about 4.5 MB,
then 10 to 40 KB for each font the drawing uses); later blocks take a fraction of a second.
- What a block may hold: a
tikzpicture(or\tikz{...}), bare drawing commands such as\draw ... ;(wrapped in atikzpicturefor you), or a whole LaTeX file with\documentclass{standalone}(border=is read),\usepackage,\usetikzlibraryand\begin{document}. Only the first picture page is drawn. - Libraries: 3d, angles, arrows, arrows.meta, automata, babel, backgrounds, bending, calc, calendar, chains, circuits (and .ee, .ee.IEC, .logic.CDH, .logic, .logic.IEC, .logic.US), datavisualization (and .3d, .barcharts, .formats.functions, .polar, .sparklines), decorations (and .footprints, .fractals, .markings, .pathmorphing, .pathreplacing, .shapes, .text), er, fadings, fit, fixedpointarithmetic, folding, fpu, graphs, graphs.standard, intersections, lindenmayersystems, math, matrix, mindmap, patterns, patterns.meta, perspective, petri, plothandlers, plotmarks, positioning, quotes, rdf, scopes, shadings, shadows, shapes (and .arrows, .callouts, .geometric, .misc, .multipart, .symbols, .gates.logic.US, .gates.logic.IEC, .gates.ee, .gates.ee.IEC), snakes, spy, svg.path, through, topaths, trees, turtle and views.
- Packages:
tikz,xcolor(with the svgnames colours),amsmathand the other AMS packages (amsfonts,amssymb,amstext,amsbsy,amsopn,amscd),array,ifthen,circuitikz(acircuitikzenvironment or\ctikzsetwork like in LaTeX),chemfig(\chemfig{...}),tikz-3dplot,eucal,eufrak,euscript,pgfcalendarandsimplekv. Fonts are Computer Modern and the AMS math fonts. - Safe by construction: TeX has no disk, network or shell here.
\write18has nothing to run,\inputand\openinfind only the bundle's own files,\openoutwrites into memory, a file name with a directory part is refused, and a run that writes more than 8 MB is stopped. A drawing that takes longer than 30 seconds (an endless loop, say) is stopped and the worker restarts for the next one. - Errors: TeX's first error is shown with the line of the block it is on, above the block's source.
\usetikzlibrary{arrows.meta, positioning}
\begin{tikzpicture}[node distance=2cm]
\node[draw, rounded corners] (a) {Source};
\node[draw, right=of a] (b) {$\sum_{i} x_i^2$};
\draw[-{Stealth}, thick] (a) -- (b);
\end{tikzpicture}
Not described
- Known, not yet covered: Viewer:
pgfplots(axis,\addplot) andtikz-cd(commutative diagrams) are not in the viewer's TeX bundle, because both are licensed GPL-3-or-later only and the site ships the LPPL parts of TikZ; a block that uses them says so. - Known, not yet covered: Viewer: the TeX of the viewer has fixed limits (parameter stack of 300 and input stack of
2000 entries), so very large
graph,mindmapor deeply nested pictures stop with "TeX capacity exceeded"; a few manual examples with big trees do this. - Known, not yet covered: Viewer:
graphdrawing(needs Lua),\includegraphicsandplot file{...}(no files),plot function{...}(needs gnuplot),remember pictureand overlays across pictures (need two TeX runs), SVG animations,\usepackage{fontspec}and other fonts, and more than the first picture page.
PlantUML
Fence words plantuml, puml and uml. PlantUML
draws UML and many other diagrams from text. The viewer runs the PlantUML project's own build of the program (the
Java program compiled to WebAssembly, offered under the MIT licence), with Graphviz for the layouts that need it,
in a background worker, and draws the result as an SVG picture. The first PlantUML block of a session fetches the
program (about 6 MB); later blocks take a fraction of a second. A block holds one document, written
@startuml ... @enduml or with the end word of another kind; a block with no @start line is
taken as the inside of @startuml.
- Drawn: sequence, use case, class, object (with
map), activity (the new syntax), component, deployment, state, timing, entity relationship (IE), Archimate, and the@startkindsmindmap,wbs,gantt,chronology,salt,json,yaml,ebnf,regex,chen,board,wire,creoleanddot. - Layout: Graphviz (the Viz.js build) for diagrams of nodes and arrows, and
!pragma layout smetanafor PlantUML's own Java layout;skinparam,<style>,!theme(the themes bundled with PlantUML), the preprocessor (!define,!function,!procedure,!while,!if, variables), sprites, emoji (<:1f600:>) and OpenIconic (<&heart>) work. - Libraries:
!include <C4/C4_Context>and the other C4 files,archimate,azure,bootstrap,cloudinsight,DomainStoryandeip, each a bundle fetched only when a diagram includes it. - Safe by construction: a
!include,!includeurl,!importor!theme ... fromthat names a web address is refused before PlantUML sees it, the worker has no network (fetch is taken away from it), a!includeof a file finds no file, a link whose address is nothttp,httpsormailtoloses its address, and a drawing that takes longer than 30 seconds is stopped. Output larger than 8192 pixels on a side is refused. - Errors: PlantUML's own message, with the line it is on, is shown above the block's source.
@startuml
actor Alice
participant Bob
Alice -> Bob : Hello
alt ok
Bob --> Alice : Hi
else not ok
Bob --> Alice : Sorry
end
@enduml
Not described
- Known, not yet covered: Viewer:
@startmathand@startlatex(they need JLaTeXMath, which is GPL, so it is not shipped) and the<math>and<latex>tags inside a diagram, which stay plain text. - Known, not yet covered: Viewer:
@startditaa(use aditaablock) andnwdiag(use annwdiagblock): the browser build of PlantUML does not contain them. - Known, not yet covered: Viewer: the standard-library bundles whose licence is not MIT or is not stated (AWS, Google Cloud, IBM,
Kubernetes, Material, Office, tupadr3 icons, logos, Elastic, AdaML and the rest) are not shipped, so an
!includeof them fails with "cannot include". - Known, not yet covered: Viewer:
!includeof a local file,!includeurl,!importand every other use of the network; PNG, ASCII art and other outputs, and the@startumlfiles of more than one diagram (only the first is drawn). - Known, not yet covered: Viewer: the browser needs WebAssembly GC (Chrome 119, Firefox 120, Safari 18.2 or later).
In the viewer
The viewer reads a file as CommonMark with these extensions, since nothing in the file
can say otherwise. Each appears as a named node in the structure tree, the HTML tab shows
what it means in HTML, and the Overview counts them. Front matter is recognised only
when the lines between the two --- markers look like YAML, so a document
that merely starts with a thematic break keeps its first lines.