#parser #markdown #html #geml

bin+lib geml

A simple Generator-orientated ML parser

30 stable releases

1.1.26 Mar 5, 2019
1.1.24 Mar 4, 2019
1.1.10 Feb 18, 2019
0.1.2 Feb 2, 2019

#506 in Text processing

Download history 236/week @ 2022-06-03 5/week @ 2022-06-10 8/week @ 2022-06-17 9/week @ 2022-06-24 37/week @ 2022-07-01 37/week @ 2022-07-08 71/week @ 2022-07-15 72/week @ 2022-07-22 134/week @ 2022-07-29 11/week @ 2022-08-05 7/week @ 2022-08-12 7/week @ 2022-08-19 36/week @ 2022-08-26 9/week @ 2022-09-02 111/week @ 2022-09-09 6/week @ 2022-09-16

164 downloads per month
Used in rust_ssg

MIT license

19KB
411 lines

GEML

GEML (GEnerator Markdown Language) is a simple string-orientated ml parser, made with regex, designed to be used with static site generators using HTML templates. Each entry is structured as a title (which is surrounded by $ when serialized), a map of tags (specified like rust attributes), and the text itself. A GemlFile is a vector of these combined with some metadata. As such, it can compile to HTML, and has it's own (somewhat limited) markdown parser.

Usage

To deserialize a GEML file, you can use the GemlFile::from_string or from_path functions: (Note that you have to specify a root path if reading from a string)

let geml = String::from("
$test1$
#[markdown(enabled)]
Note that markdown is enabled by default.
*markdown*, cool.
");
let deserialized = GemlFile::from_string(geml, Path::new("root/dir/")).unwrap();

You can also serialize a vector of raw GEML using Geml::deserialize:

let geml = String::from("
$test1$
#[markdown(enabled)]
Note that markdown is enabled by default.
*markdown*, cool.
");
let deserialized = Geml:deserialize(geml).unwrap();

The main idea behind GEML is that the SSG looks for GEML-style titles in an HTML template, and then replaces them with the corresponding GEML's value.

So the template:

<html>
<body>
$test1$
</body>
</html>

Would become:

<html>
<body>

Note that markdown is enabled by default.
<em>markdown</em>, cool.

</body>
</html>

Test, Please Ignore

Dependencies

~1–1.3MB
~38K SLoC