aboutsummaryrefslogtreecommitdiff
path: root/examples/md-to-html/convert.tbsp
blob: 103bcaa241eb34d867234ceb01e378e83b141207 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
BEGIN {
    int depth = 0;

    print("<html>\n");
    print("<body>\n");
}

enter section {
    depth += 1;
}
leave section {
    depth -= 1;
}

enter atx_heading {
    print("<h");
    print(depth);
    print(">");
}
leave atx_heading {
    print("</h");
    print(depth);
    print(">\n");
}

enter paragraph {
    print("<p>");
}
leave paragraph {
    print("</p>\n");
}

enter list {
    print("<ol>");
}
leave list {
    print("</ol>\n");
}

enter list_item {
    print("<li>");
}
leave list_item {
    print("</li>\n");
}

enter fenced_code_block {
    print("<pre>");
}
leave fenced_code_block {
    print("</pre>\n");
}

enter inline {
    print(text(node));
}
enter code_fence_content {
    print(text(node));
}

END {
    print("</body>\n");
    print("</html>\n");
}