liquid_grammar_pest/lib.rs
1#!/usr/bin/env rust
2
3//! ## Example MarkDown/Liquid input
4//!
5//! ```markdown
6//! ---
7//! # YAML comment
8//! title: Super awesome post
9//! description: A post about some topic
10//! ---
11//!
12//! Content of post before Liquid code
13//!
14//! {% if collection %}
15//! <ul>
16//! {% for item in collection %}
17//! <li>{{ item }}</li>
18//! {% endfor %}
19//! </ul>
20//! {% endif %}
21//!
22//! Content of post after Liquid code
23//! ```
24//!
25//! ## Expected parser result
26//!
27//! ```text
28//! - document
29//! - front_matter > yaml_content: "# YAML comment\ntitle: Super awesome post\ndescription: A post about some topic\n"
30//! - content__block: "\n\nContent of post before Liquid code\n\n"
31//! - liquid__block__control_flow__branch__outside_iteration > liquid__block__control_flow__branch__outside_iteration__plain
32//! - liquid__block_subsection__control_flow__branch__outside_iteration__plain__start
33//! - liquid__tag__open__plain: "{%"
34//! - liquid__key_word__control_flow__branch: "if"
35//! - liquid__code__control_flow__branch__comparison__expression > liquid__code__control_flow__branch__comparison__expression__pair
36//! - liquid__code__control_flow__branch__comparison__operator__word > liquid__type > object > object__word: "collection"
37//! - liquid__code__control_flow__branch__comparison__operator > greater: ">"
38//! - liquid__code__control_flow__branch__comparison__operator__word > liquid__type > number: "0"
39//! - liquid__tag__close__plain: "%}"
40//! - content__block: "\n<ul>\n "
41//! - liquid__block__iteration__for > liquid__block__iteration__for__plain
42//! - liquid__block_subsection__iteration__for__plain__start
43//! - liquid__tag__open__plain: "{%"
44//! - liquid__key_word__iteration__for: "for"
45//! - object__word: "item"
46//! - liquid__code__iteration__target > object > object__word: "collection"
47//! - liquid__tag__close__plain: "%}"
48//! - content__block: "\n<li>{{ item }}</li>\n "
49//! - liquid__tag__plain__end
50//! - liquid__tag__open__plain: "{%"
51//! - liquid__code__end: "endfor"
52//! - liquid__tag__close__plain: "%}"
53//! - content__block: "\n</ul>\n"
54//! - liquid__tag__plain__end
55//! - liquid__tag__open__plain: "{%"
56//! - liquid__code__end: "endif"
57//! - liquid__tag__close__plain: "%}"
58//! - content__block: "\n\nContent of post after Liquid code\n"
59//! - EOI: ""
60//! ```
61
62// TODO: Sort out why documentation says to have following `use` but compiler complains
63// use pest::Parser;
64use pest_derive::Parser;
65
66#[derive(Debug, Parser)]
67#[grammar = "grammars/liquid.pest"]
68pub struct LiquidParser;
69