Mendoza markup is used to create the main content of your pages. It is mostly plain-text that is read by mendoza, transformed into a document tree, and then rendered to the final HTML for presentation.
All mendoza markup files must contain some front matter. The front
provides basic metadata for the document, parameters for templating, and
whatever Janet code you want to execute for side effects. The front matter
is just Janet source code and continues up until the ---
. The last
value in the front matter should be a table or struct, and will be merged
into the root node of the final document tree.
Example:
{:title "My Blog Post"
:description "Mendoza is a new static site generator!"
:template "main.html"}
# End of front matter
---
# Markup here...
After the front matter, the basic syntax of Mendoza markup is pretty simple. Blocks of plain text separated by blank lines become paragraphs. Mendoza supports UTF-8, so there is no need to escape characters. To escape a byte, use a backslash followed by the byte.
Simple, markdown like headers occur at the beginning of a line.
They are formed by 1 to 6 #
characters in a line, followed
by the header title.
For all other markup, Mendoza requires the use of macros. Headers and paragraphs can be specified with macros as well, but there is direct syntactic support for these because they are so common.
Macros correspond to Janet functions, which will evaluate the arguments and
return a DOM node to be inserted into the document. You can call normal Janet
functions in the code, as well other functions defined in the macro
environment. Macro calls begin with a @
character, followed by the name
of the macro.
For example:
This is some @green-thing text
In this case @green-thing
is not a real macro, but if it were, the value of (green-thing)
from Janet would be spliced into the DOM.
We can also pass arguments to macros in several ways.
@green-thing(1 true nil)
will be transformed to (green-thing 1 true nil)
@green-thing[1 true nil]
will be transformed to (green-thing "1 true nil")
@green-thing{More stuff @bold[here]}
will be transformed to (green-thing ["More stuff " {:tag "bold" :content "here"}])
(or something similar).@mymac`a string`
, @mymac"a string"
You can also put different kinds of arguments together for expresive macros. For example, the
@codeblock
macro can be used with this technique to great effect.
@codeblock[janet]```
(+ 1 2 3)
```
The codeblock macro takes two string arguments, where the first specifies the language to use for highlighting, and the second is the code to format, which is given as a Janet multi-line backtick string. You could also write
@codeblock[janet][(+ 1 2 3)]
as both forms pass two strings to the codeblock macro.