Skip to content

Commit 3a91556

Browse files
committed
Add a test for frontmatters
1 parent 63f57c5 commit 3a91556

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{0 Title}
2+
3+
{@frontmatter[
4+
bli1: bloblobloblo1
5+
bli2: bloblobloblo2
6+
]}

test/pages/frontmatter.t/run.t

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
When there is no frontmatter, everything is normal
2+
3+
$ odoc compile zero_frontmatter.mld
4+
$ odoc_print page-zero_frontmatter.odoc | jq '.frontmatter'
5+
"None"
6+
7+
When there is one frontmatter, it is extracted from the content:
8+
9+
$ odoc compile one_frontmatter.mld
10+
$ odoc_print page-one_frontmatter.odoc | jq '.frontmatter'
11+
{
12+
"Some": [
13+
[
14+
"bli1",
15+
" bloblobloblo1"
16+
],
17+
[
18+
"bli2",
19+
" bloblobloblo2"
20+
]
21+
]
22+
}
23+
$ odoc_print page-one_frontmatter.odoc | jq '.content'
24+
[
25+
{
26+
"`Heading": [
27+
{
28+
"heading_level": "`Title",
29+
"heading_label_explicit": "false"
30+
},
31+
{
32+
"`Label": [
33+
{
34+
"`LeafPage": [
35+
"None",
36+
"one_frontmatter"
37+
]
38+
},
39+
"title"
40+
]
41+
},
42+
[
43+
{
44+
"`Word": "Title"
45+
}
46+
]
47+
]
48+
}
49+
]
50+
51+
When there is more than one frontmatter, they are all extracted from the content:
52+
53+
$ odoc compile two_frontmatters.mld
54+
$ odoc_print page-two_frontmatters.odoc | jq '.frontmatter'
55+
{
56+
"Some": [
57+
[
58+
"bli1",
59+
" bloblobloblo1"
60+
],
61+
[
62+
"bli2",
63+
" bloblobloblo2"
64+
]
65+
]
66+
}
67+
$ odoc_print page-two_frontmatters.odoc | jq '.content'
68+
[
69+
{
70+
"`Heading": [
71+
{
72+
"heading_level": "`Title",
73+
"heading_label_explicit": "false"
74+
},
75+
{
76+
"`Label": [
77+
{
78+
"`LeafPage": [
79+
"None",
80+
"two_frontmatters"
81+
]
82+
},
83+
"title"
84+
]
85+
},
86+
[
87+
{
88+
"`Word": "Title"
89+
}
90+
]
91+
]
92+
},
93+
{
94+
"`Code_block": [
95+
{
96+
"Some": "frontmatter"
97+
},
98+
"bli3: bloblobloblo1"
99+
]
100+
}
101+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{0 Title}
2+
3+
{@frontmatter[
4+
bli1: bloblobloblo1
5+
bli2: bloblobloblo2
6+
]}
7+
8+
{@frontmatter[
9+
bli3: bloblobloblo1
10+
]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{0 No frontmatter}

0 commit comments

Comments
 (0)