L0 Markup Demo
L0
Open file
About
Table of Contents
Introduction
Additions
Block verbatim
Bulleted lists
Numbered lists
Widgets
Tables
Computations
Graphs
Technical Notes
Table of Contents
Footnote
The L0 Markup Language (Draft)
image
The L0 Mascot
Introduction
L0 is a simple yet versatile markup language that takes inspiration from Lisp. An L0 document consists of ordinary text and
"M-expressions"
, e.g.,
[blue flowers]
, which is rendered as
flowers
. M-expressions can be nested, as in
[blue [i delicate blue] flowers]
, which renders as
delicate blue
flowers
.
In addition to the
"pure L0"
just described, we have borrowed from Markdown. For example, inline code can set off by backticks:
This is code: `a[i] = a[i] + 1`
Here is the rendered version:
This is code:
a[i] = a[i] + 1
The version of L0 that you see here is implemented in
Elm
using the
Camperdown
library. Camperdown is an open-source version of the fault-tolerant parser developed at
Briliant.org
for the tools used by the authors of their courses in STEM fields. Because Camperdown is a
configurable
parser, it can be used to build quite a variety of apps, e.g.,
Additions
Let us discuss the additions made to pure L0
Block verbatim
With block verbatim you can write multi-line code or anything else that you wish to be rendered as-is. A verbatim block consists of the string
%%%
followed by text which
must
be indendented
%%% This is verbatim text As you
The verbatim block is rendered like this:
This is verbatim text As you can see, white space is preserved.
Bulleted lists
Bulleted lists are constructed like this
! bulleted [item Do this.] [item Do that.] [item And then do the other thing.]
They render as shown below.
Do this.
Do that.
And then do the other thing.
The
"bang"
symbol
"!"
announces a Campedown command. The bang symbol is followed by a space, then the name of the command, then the chevron
">>>"
. Followng the chevron are the children of the command, which are orginary M-expressions. This construction allows one to have multi-paragraph constructions, something that is not possible in pure L0. This is because an M-expressiion may not contain empty lines, or for that matter, lines with whitespace only.
Numbered lists
Numbered lists are much like bulleted lists:
! numbered [item Do this.] [item Do that.] [item And then do the other thing.]
They render as shown below.
1.
Do this.
2.
Do that.
3.
And then do the other thing.
Widgets
In L0, one can easily implement
widgets
that display data, carry out computations, or produce graphical output.
Tables
[datatable H, 1, 1.008; He, 2, 4.003;]
H
1
1.008
He
2
4.003
Li
3
6.940
Be
4
9.012
B
5
10.810
C
6
12.011
N
7
14.007
O
8
15.999
F
9
18.998
Ne
10
20.180
Computations
[sum 11.4 4.5 -7.7]
It renders as
sum
11.4
4.5
-7.7
=
8.2
One can also specify a precision:
[sum [opt precision:3] 0.02 0.015 -0.009]
This renders as
sum
0.02
0.015
-0.009
=
0.026
Graphs
[bargraph 1.2, 1.3, 2.4, 3.1, 2.9, 2.2, 1.8, 2.5, 2.7]
00.61.21.92.53.1
data points: 9,
min: 1.2,
max: 3.1
Technical Notes
While the Camperdown parser was not designed with a markup language like L0 in mind, it is easy to use it as an L0 parser.
The first step is to modify the standard configuration for the parser so that annotations of
the form
[ ... whatever ...]
are not required to have an immediately following command,
as in the form
[ ... whatever ...](command)
.
elementToMExpression : Syntax.Element -> MExpression
where
type MExpression = Literal String | Verbatim Char String | MElement String MExpression | MList (List MExpression) | MProblem String
Once this is done, one can work entirely within the MExpression universe.
Table of Contents
The table of contents is constructed from the parsed document, viewed as a list of M-expressions. This list is filtered, retaining on MElements whose name includes
"heading"
. The table of contents is constructed from this list.
Footnote
For those curious about the origin of the name
"Camperdown parser"
, the clue is in the photograph below. Taken in Prospect Park, Brooklyn, its subject is a particular interesting species of Elm tree,
Ulmus glabra 'Camperdownii'
. Courtesy of Wikimedia Foundation.
image
Camperdown Elm Tree