Djot
3 January 2023; 20 months ago (3 January 2023)
Djot (/dʒɑt/) is a lightweight markup language that aims to improve on CommonMark's syntax where it is complex and difficult to parse efficiently.[3] It was created in 2022 by John MacFarlane, the author of Pandoc and a member of the CommonMark standardization group.[4][5]
It derives most of its features from CommonMark, but includes a wider set of features, including description lists, footnotes, tables, several new kinds of inline formatting, math and smart punctuation.[3]
The original reference implementation is written in a scripting language (Lua), but the language is designed to parse efficiently, so it is very fast.[6]
The code and documentation are released under the MIT License.[7]
Difference from CommonMark
Djot's syntax is similar to CommonMark's, but there are some differences.[8]
Blank lines
CommonMark does not need blank lines around block-level elements, but Djot does.
Example:
Input | Corresponding HTML produced by a CommonMark processor | Corresponding HTML produced by a Djot processor |
---|---|---|
# Heading
Paragraphs.
| <h1>Heading</h1> <p>Paragraphs.</p> | <h1>Heading Paragraphs.</h1> |
# Heading
Paragraphs.
| <h1>Heading</h1> <p>Paragraphs.</p> | <h1>Heading</h1> <p>Paragraphs.</p> |
Input | Corresponding HTML produced by a CommonMark processor | Corresponding HTML produced by a Djot processor |
---|---|---|
* fruits * apple * banana | <ul> <li>fruits <ul> <li>apple</li> <li>banana</li> </ul> </li> </ul> | <ul> <li>fruits * apple * banana </li> </ul> |
* fruits * apple * banana | <ul> <li><p>fruits</p> <ul> <li>apple</li> <li>banana</li> </ul> </li> </ul> | <ul> <li>fruits <ul> <li>apple</li> <li>banana</li> </ul> </li> </ul> |
Headings
Djot has no setext (=
or -
) headings, only ATX (#
) headings.
Example:
Text using CommonMark syntax | Text using Djot syntax | Corresponding HTML produced |
---|---|---|
Heading ======= Sub-heading ----------- | # Heading ## Sub-heading | <h1>Heading</h1> <h2>Sub-heading</h2> |
Emphasis
CommonMark uses single *
or _
for emphasis, and double *
or _
for strong emphasis. Djot uses single _
for emphasis, and single *
for strong emphasis.
Example:
Text using CommonMark syntax | Text using Djot syntax | Corresponding HTML produced |
---|---|---|
Text attributes _italic_, **bold**. | Text attributes _italic_, *bold*. | <p>Text attributes <em>italic</em>, <strong>bold</strong>.</p> |
Links
Unlike CommonMark, Djot has no special syntax for adding a title to a link. A title can be added by using the general attribute syntax instead.
Example:
Text using CommonMark syntax | Text using Djot syntax | Corresponding HTML produced |
---|---|---|
A [link](http://example.com "title"). | A [link](http://example.com){title="title"}. | <p>A <a href="http://example.com" title="title">link</a>.</p> |
Examples
Text using Djot syntax | Corresponding HTML produced by a Djot processor | Text viewed in a browser |
---|---|---|
# Heading ## Sub-heading Paragraphs are separated by a blank line. The backslash at the end of a line\ produces a line break. | <h1>Heading</h1> <h2>Sub-heading</h2> <p>Paragraphs are separated by a blank line.</p> <p>The backslash at the end of a line<br> produces a line break.</p> | Heading Sub-heading Paragraphs are separated by a blank line. The backslash at the end of a line |
Text attributes _italic_, *bold*, `monospace`. Horizontal rule: * * * | <p>Text attributes <em>italic</em>, <strong>bold</strong>, <code>monospace</code>.</p> <p>Horizontal rule:</p> <hr> | Text attributes italic, bold, monospace . Horizontal rule: |
Bullet lists nested within a numbered list: 1. fruits * apple * banana 2. vegetables - carrot - broccoli | <p>Bullet lists nested within a numbered list:</p> <ol> <li>fruits <ul> <li>apple</li> <li>banana</li> </ul> </li> <li>vegetables <ul> <li>carrot</li> <li>broccoli</li> </ul> </li> </ol> | Bullet lists nested within a numbered list:
|
A [link](http://example.com). ![Image](Icon-pictures.png){title="icon"} > Djot uses email-style characters for blockquoting. > > Multiple paragraphs need to be prepended individually. Raw content such as inline `<abbr title="Hypertext Markup Language">HTML</abbr>`{=html} tags must be explicitly marked. | <p>A <a href="http://example.com">link</a>.</p> <p><img alt="Image" title="icon" src="Icon-pictures.png"></p> <blockquote> <p>Djot uses email-style characters for blockquoting.</p> <p>Multiple paragraphs need to be prepended individually.</p> </blockquote> <p>Raw content such as inline <abbr title="Hypertext Markup Language">HTML</abbr> tags must be explicitly marked.</p> | A link.
Raw content such as inline HTML tags must be explicitly marked. |
Implementations
Name | License | Language | Repository | Description |
---|---|---|---|---|
djot.js | MIT License | TypeScript | https://github.com/jgm/djot.js | This is a TypeScript rewrite of the original reference implementation. |
djot.lua | MIT License | Lua | https://github.com/jgm/djot.lua | The original reference implementation. |
Jotdown | MIT License | Rust | https://github.com/hellux/jotdown | Pull parser implemented as a Rust library |
Djota | BSD 3-clause license | Prolog | https://github.com/aarroyoc/djota | Implementation in Prolog |
djoths | MIT License | Haskell | https://github.com/jgm/djoths | Haskell library and command-line tool |
godjot | MIT License | Go | https://github.com/sivukhin/godjot | Implementation in Go |
Uses
- Starting from version 3.1.12, Pandoc supports Djot as an input format and an output format.[9]
References
- ^ "File extension". github.com. Retrieved 2023-01-24.
- ^ "Release 0.2.0". 3 January 2023. Retrieved 8 January 2023.
- ^ a b "Djot (/dʒɑt/)". djot.net. Retrieved 2022-08-13.
- ^ MacFarlane, John (2022-07-11). "Initial commit". github.com. Retrieved 2022-08-13.
- ^ MacFarlane, John. "Tools". johnmacfarlane.net. Retrieved 2022-08-13.
- ^ "README.md". github.com. Retrieved 2023-01-24.
- ^ "License". github.com. Retrieved 2022-08-13.
- ^ "Quick Start for Markdown users". github.com. Retrieved 2022-08-14.
- ^ "pandoc 3.1.12 (2024-02-14)". pandoc.org. Retrieved 2024-03-05.
External links
- Official website