Markdown spec#
Introduction#
md-toc aimes to be as conformant as possible to each supported markdown parser. What follows is a list of parameters and rules used by md-toc to decide how to parse markdown files and to generate the table of contents.
Compatibility table#
Key#
Color |
Meaning |
---|---|
unknown |
|
none |
|
low |
|
partial |
|
good |
|
most |
|
full |
Status#
Parser |
Status |
Alias of |
Supported parser version |
Source |
---|---|---|---|---|
|
- |
Version 0.30 (2021-06-19) (GIT tag 0.30.0) |
||
|
|
- |
||
|
- |
Version 0.29-gfm (2019-04-06) (GIT tag 0.29.gfm.0) |
||
|
|
- |
||
|
- |
Latest unknown version |
||
|
- |
|||
Gogs |
- |
- |
||
NotABug Gogs fork |
- |
- |
||
Marked |
- |
- |
||
kramdown |
- |
- |
||
GitLab Kramdown |
- |
- |
||
Notabug |
- |
- |
md-toc version tables#
Key#
Word |
Meaning |
---|---|
✘ |
not implemented |
C |
Commonmark |
G |
GitLab modified Redcarpet |
If a parser is not present in a version table it means that at that moment it was not implemented.
Status history#
Version 0#
md-toc |
|
---|---|
0.0.1 |
unknown version |
Version 1#
md-toc |
|
|
|
|
---|---|---|---|---|
1.0.0 |
unknown version |
latest version |
G |
Version 2#
md-toc |
|
|
|
|
|
---|---|---|---|---|---|
2.0.0 |
latest version |
latest version |
C |
G |
|
2.0.1 |
latest version |
latest version |
C |
G |
Version 3#
md-toc |
|
|
|
|
|
---|---|---|---|---|---|
3.0.0 |
|
|
0.28.gfm.? |
|
|
3.1.0 |
|
|
0.28.gfm.? |
|
Version 4#
md-toc |
|
|
|
|
|
---|---|---|---|---|---|
4.0.0 |
|
|
0.28.gfm.? |
|
Version 5#
md-toc |
|
|
|
|
|
---|---|---|---|---|---|
5.0.0 |
|
|
0.28.gfm.? |
|
|
5.0.1 |
|
|
0.28.gfm.? |
|
Version 6#
md-toc |
|
|
|
|
|
---|---|---|---|---|---|
6.0.0 |
|
|
0.28.gfm.? |
|
|
6.0.1 |
|
|
0.28.gfm.? |
|
|
6.0.2 |
|
|
0.28.gfm.? |
|
Version 7#
md-toc |
|
|
|
|
|
---|---|---|---|---|---|
7.0.0 |
|
|
0.28.gfm.? |
|
|
7.0.1 |
|
|
0.28.gfm.? |
|
|
7.0.2 |
|
|
0.28.gfm.? |
|
|
7.0.3 |
|
|
0.28.gfm.? |
|
|
7.0.4 |
|
|
0.28.gfm.? |
|
|
7.0.5 |
|
|
0.28.gfm.? |
|
|
7.1.0 |
|
|
0.28.gfm.? |
|
v3.5.0 |
7.2.0 |
0.28.? [1] |
0.28.gfm.? |
0.28.gfm.? |
|
v3.5.0 |
Version 8#
md-toc |
|
|
|
|
|
|
---|---|---|---|---|---|---|
8.0.0 |
0.29.? |
|
0.29.gfm.? |
latest version |
|
v3.5.0 |
8.0.1 |
0.29.? |
|
0.29.gfm.? |
latest version |
|
v3.5.0 |
8.1.0 |
0.29.? |
|
0.29.gfm.? |
latest version |
|
v3.5.0 |
8.1.1 |
0.30.? |
|
0.29.gfm.? [2] |
latest version |
|
v3.5.0 |
8.1.2 |
0.30.? |
|
0.29.gfm.? [2] |
latest version |
|
v3.5.0 |
8.1.3 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.1.4 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.1.5 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.1.6 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.1.7 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.1.8 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.1.9 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.2.0 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.2.1 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.2.2 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
8.2.3 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
Version 9#
md-toc |
|
|
|
|
|
|
---|---|---|---|---|---|---|
9.0.0 |
0.30.0 |
|
0.29.gfm.0 [2] |
latest version |
|
v3.5.0 |
Supported markdown parsers#
cmark
:“CommonMark parsing and rendering library and program in C”.
commonmarker
:a “Ruby wrapper for libcmark (CommonMark parser)”.
as described on their website: “It also includes extensions to the CommonMark spec as documented in the GitHub Flavored Markdown spec, such as support for tables, strikethroughs, and autolinking.”. For this reason we assume that
commonmarker
is an alias ofgithub
.
github
:uses a forked version of
cmark
with some added extensions. This language specification is called GitHub Flavored Markdown.there are subtle differences that affect md-toc such as
the disallowed raw HTML extension which affects md-toc
emphasis processing
gitlab
:uses
commonmarker
. Older versions of md-toc, prior to version3.0.0
, usegitlab
as an alias ofredcarpet
while newer versions usegithub
instead. In the past GitLab used Redcarpet as markdown parser.some extensions used in GitLab Flavored Markdown, not to be confused with GitHub Flavored Markdown, are different from the ones used in GitHub Flavored Markdown.
See also
Documentation Style Guide | GitLab - Documentation is the single source of truth (SSOT) [3]
goldmark
:this parser claims to be compliant with CommonMark: goldmark is compliant with CommonMark 0.30.. For this reason
goldmark
is an alias ofcmark
.
redcarpet
:“The safe Markdown parser, reloaded.”
Other markdown parsers#
If you have a look at [4] you will see that there are a ton of different markdown parsers out there. Moreover, that list has not been updated in a while.
Markdown parsers have different behaviours regarding anchor links. Some of them implement them while others don’t; some act on the duplicate entry problem while others don’t; some strip consecutive dash characters while others don’t. And it’s not just about anchor links, as you can read in the rules section. For example:
Gitea apparently uses
goldmark
as markdown parser. See [5] [6]. There are same cases where there is a discrepancy withcmark
:this is - a test
is rendered asthis-is---a-test
by cmarkthis-is-a-test
by Gitea
Gitea adds an annoying
user-content
substring in the TOC’s anchor links. This is true for versions since git tag v1.11.0. See [7] [8] [9] [10].The
user-content
substring does not seem to affect the functionality of the TOC.Older versions of Gitea used blackfriday. See [11].
Gogs uses Marked as the markdown parser. See [12] [13] [14] [15].
Notabug: Notabug is powered by a liberated version of gogs. See [16].
Kramdown: It is unclear if this feature is available. See [17]
Gitlab Kramdown. See [18]
Steps to add an unsupported markdown parser#
Find the source code and/or documents.
Find the rules for each section, such as anchor link generation, title detection, etc… Rely more on the source code than on the documentation (if possible)
Add the relevant information on this page.
Write or adapt an algorithm for that section.
Write unit tests for it.
Add the new parser to the CLI interface.
Footnotes