Markup Language 9

Markup Language 9 (or just ml9) is a simple markup language handling many different types of data in a single unified framework.

Ml9 documents are designed to be written with a standard text editor (like emacs) - they can be processed in many different ways.

I'd welcome any feedback on the ML 9 wiki page of the Erlang wiki.

Mixing different things in the same file

Let's start off with a simple example, suppose we want to mix Makefiles, Erlang and Java in a single document, how can we do this?. Easy! - just create an ml9 file with the following content.

This is pretty easy to understand. Easy section starts with a @tag in column 1 and ends with the character immediately before the start of the next tag.

The data associated with each tag starts immediately after the end of the tag - note that this data is uninterpreted and unquoted - it's just a stream of bytes terminated with a @ in column 1 following a carriage return.

The parse tree of:

is just

Adding meta data to the data

Sometimes we want top add meta data to the data. Meta data is data which describes the data and is not part of the data itself. Suppose we want a yellow preformatted block. The tag is pre the meta datais color=yellow. This we can write like this:

Which might get rendered like this:
    
    This is a yucky yellow
    block of pre-formatted data

Yunck.

ML9 chunks format

Each block of data in an ml9 document is called a chunk, chunks are written like this:

The {Key1=Val1, ...KeyN=ValN} is meta data. The string AAA...ZZZZ is parsed just as if we had defined a tag named data whose value is the string AAA...ZZZ'''. Thus

and

Have identical parse trees.

Autoxec

Now the fun starts. If the first tag in a file is written like this:

Then the shell command:

Will cause the ml9 file to parsed and the Erlang expression Mod:exec(File, Parse) will be evaluated. Here Parse is the Erlang parse tree of the ml9 file, and File is the filename supplied on the command line.

This is a very powerful mechanism, since it turns every ml9 file into a potential program. Indeed the ml9 file containing this documentation starts with the line:

Just you interest you can look at doc.ml9 to get an idea of how simple the syntax of an ml9 file can be. Translation of ml9 into html is really easy. The ml9_2_html handler is really easy take a look at the code.

Comparison with XML

XML data structures are basically like this

The name=Val1 etc can be thought of as being meta data. The body of the data structure ... data ... is structured data.

In XML the meta data is simple and flat ie keywords and values are just simple strings with no structure. Data on the other hand is complex ie can have structure.

ML9 is completely the opposite - both keys are values are arbitrarily complex Erlang terms. Data is flat - ie an uninterpreted stream of bytes.

Since the data is just a stream of bytes, its interpretation depends entirely upon the values of specific items in the meta-data. Thus

Means the data following the tag is in Erlang syntax etc. The easiest way to view a chunks document is to see what the input to this document was. this was the input to this document.

Images and Links

Links can be written like doc.ml9 or joe's home page or http://erlang.sics.se/

Download

Here is the code ml9.tgz.

About ML 9

ML9 was developed to be the input language for ErlGuten.

There is no significance in the name. I wanted UML Universal Markup Language but this was taken - as was SML Simple Markup Language.