Introduction
Mark Zero is a lightweight markup language similar to Markdown or Org-mode. At the moment, it can be exported to HTML and contains features suitable for writing programming articles.
Inline Syntax
The inline syntax of Mark Zero is similar to its predecessors. It has *bold*, _italics_, and `verbatim`, which can be _*`combined`*_. Mark Zero is fairly clever about deciding whether * or _ should be used to open or close bold or italics. For instance, if you write "_shout!_", you get "shout!". The exclamation mark is italicized, whereas the quotes are not. This is the result I would expect.
Verbatim can use multiple backticks so that you can have backticks inside of a verbatim span: `` `verbatim` ``. I copied this feature from Djot.
Links and Square Brackets
Mark Zero has also has links. They are written <https://example.com>[like this], which renders like this. When no link text is provided, links are rendered by their URLs: <https://example.com> just shows up as https://example.com. Images reuse this syntax with the img: pseudo-scheme.
Here is an image:
Other than looking for the img: prefix, no URL validation is performed.
Square Brackets
Square brackets play a similar role to spans in HTML, with a few special cases like links. You can apply custom styles like so: [\red this text is red]. They can also be used to apply intraword bold and italics: splendid!. You can also associate IDs with them: [#definition-of-something something].
References
Mark Zero also has references, which serve to organize and access local resources. References are defined with the syntax #my-reference and accessed with the syntax @my-reference[link text]. They may be defined only at the beginning of a block or a span but may be accessed anywhere in regular prose.
They resemble links, and by default they behave similarly. However, they support custom prefixes using the syntax @prefix:my-reference. References may be verified and translated to HTML in an application specific manner, whereas links are handled in a more straightforward manner.
The only prefix currently supported is fn:, which denotes a file-local footnote. Thus, one may define a footnote as #fn:some-footnote and reference it as @fn:some-footnote. Footnotes are automatically numbered, backlinked, and placed at the end of the page or article; and references to them are displayed by number in superscript.1
Block Syntax
Mark Zero's block syntax diverges more from its predecessors. There are five built in block types, which are distinguished by their first character:
-
Paragraphs (no special character)
-
Headings (
=) -
Thematic Breaks (
=) -
Lists (
-) -
Code Blocks (
|)
Paragraphs, Headings, and Thematic Breaks
A paragraph is simply any block that does not have a distinguishing token.
Headings use the = symbol. For example,
= Heading 1
== Heading 2
and so on.
A thematic break is an empty heading of any level. The level makes no difference. In the following example, Paragraph 1 is separated from Paragraph 2 by a thematic break.
Paragraph 1.
===
Paragraph 2.
Code blocks use the | character. For example,
| #include "stdio.h"
|
| int main() {
| printf("hello world\n");
| return 0;
| }
Lists
Lists begin with the - character, and can contain any other block type including other lists. For example:
- Item 1
Still Item 1
- Still Item 1, sublist
- The next item in the same sublist
- === Item 2, a heading of level 3
A paragraph in item 2.
===
Yes, thematic breaks can go in lists as well.
| As can code blocks.
This paragraph is _not_ in the list.
Because lists may contain blank lines, two consecutive lists must be separated by two blank lines:
- List 1, Item 1
- List 1, Item 2
- List 2, Item 1
- List 2, Item 2
Custom Blocks
If the built-in block types don't get the job done, Mark Zero also has custom blocks. You have already seen one, which was used to center the image back in the section on links and images.
For the moment, Mark Zero has no intrinsic knowledge of any particular type of custom block; it just exports them to HTML so that you can apply custom styles. Thus
For example:
\example Here is the example
isn't it fascinating?
will be translated as
For example:
<div class="example">
Here is the example
</div>
isn't it fascinating?
Nested Blocks
In Mark Zero, blocks can be nested with indentation. This is immediately useful when dealing with lists, but it works with other types of block as well. For instance, here are the logos on my homepage:
The markup to produce them is:
\flex
<img:/img/voting.png>[The Voting Systems Logo: a
2D-grid with voters colored to match their preferred
candidate.]
<img:/img/m0.png>[The M0 Logo: the M and 0 in gold]
<img:/img/squirrel.png>[The Critter Logo: a red,
pixelated squirrel]
Together, indentation sensitivity and custom blocks are the distinguishing features of Mark Zero. They provide a suprising degree of flexibility at the cost of little implementation complexity.
HTML Export
Eventually, you are going to want to export your document to a format with more than a single-digit number of users. Mark Zero currently exports to HTML, with a few caveats.
For the moment, all top-level blocks are wrapped in an additional div with class block. In HTML, unlike in Mark Zero, a list cannot be nested inside of a paragraph. Instead, the paragarph and list are flattened and wrapped in a block. Then, the margins inside of the block are set to zero. That is,
Paragraph
- Item 1
- Item 2
rest of paragraph...
gets translated to
<div class="block">
<p>Paragraph</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<ul>
<p>rest of paragraph...</p>
</div>
which can be styled
.block {
margin : 0 1em;
p, ul { margin : 0; }
}
to give the impression that the block is a single paragraph. Inline elemenst are translated in a far more straightforward way.
Also, Mark Zero does not support any metadata or frontmatter and does not produce complete HTML documents. It only produces content suitable for the body of the HTML document. I am using Soupault for templating.
Footnotes
This footnote was actually written just after it was referenced but was moved to the end of the file automatically. The text of the original file was
[...] and references to them are displayed by number
in superscript.@fn:example-footnote
#fn:example-footnote
This example footnote was actually writen just after
[...]