Djot
| Filename extension | .dj[1] |
|---|---|
| Developed by | John MacFarlane |
| Type of format | Lightweight markup language |
| Extended from | CommonMark |
| Open format? | Yes |
| Website | {{{1}}} |
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.[2] It was created in 2022 by John MacFarlane, the author of Pandoc and a member of the CommonMark standardization group.[3][4]
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.[2]
The original reference implementation is written in a scripting language (Lua), but the language is designed to parse efficiently, so it is very fast.[5]
The code and documentation are released under the MIT License.[6]
Difference from CommonMark
Djot's syntax is similar to CommonMark's, but there are some differences.[7]
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>
|
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).
{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. |
References
- ↑ "File extension" (in en). https://github.com/jgm/djot#file-extension.
- ↑ 2.0 2.1 "Djot (/dʒɑt/)" (in en). https://djot.net/.
- ↑ MacFarlane, John (2022-07-11). "Initial commit" (in en). https://github.com/jgm/djot/commit/b95dc83ca7d233fb466c432d489cad5a09ce2200.
- ↑ MacFarlane, John. "Tools" (in en). https://johnmacfarlane.net/tools.html.
- ↑ "README.md" (in en). https://github.com/jgm/djot.lua#readme.
- ↑ "License" (in en). https://github.com/jgm/djot#license.
- ↑ "Quick Start for Markdown users" (in en). https://github.com/jgm/djot/blob/main/doc/quickstart-for-markdown-users.md.
External links
