Skip to content

Commit 165426c

Browse files
authored
feat(parser): add index term support with type-safe IndexTermKind (#274)
* feat(parser): add index term support with type-safe `IndexTermKind` Add support for `AsciiDoc` index terms (issue #260): - Flow terms (visible): ((term)) or indexterm2:[term] - Concealed terms (hidden): (((term,secondary,tertiary))) or indexterm:[...] Introduce `IndexTermKind` enum that makes invalid states unrepresentable: - Flow variant can only hold a single term (no hierarchy) - Concealed variant supports primary/secondary/tertiary terms Closes #260. * feat(html,manpage,terminal): add visible index terms
1 parent 1624587 commit 165426c

File tree

12 files changed

+799
-112
lines changed

12 files changed

+799
-112
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
= Index Terms Test
2+
3+
This is about ((Arthur)) the king.
4+
5+
(((Sword, Broadsword)))A concealed term for swords.
6+
7+
Using macro style: indexterm2:[Excalibur].
8+
9+
And concealed macro: indexterm:[Knights, Round Table].
Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
{
2+
"name": "document",
3+
"type": "block",
4+
"header": {
5+
"title": [
6+
{
7+
"name": "text",
8+
"type": "string",
9+
"value": "Index Terms Test",
10+
"location": [
11+
{
12+
"line": 1,
13+
"col": 3
14+
},
15+
{
16+
"line": 1,
17+
"col": 18
18+
}
19+
]
20+
}
21+
],
22+
"location": [
23+
{
24+
"line": 1,
25+
"col": 1
26+
},
27+
{
28+
"line": 1,
29+
"col": 18
30+
}
31+
]
32+
},
33+
"attributes": {},
34+
"blocks": [
35+
{
36+
"name": "paragraph",
37+
"type": "block",
38+
"inlines": [
39+
{
40+
"name": "text",
41+
"type": "string",
42+
"value": "This is about ",
43+
"location": [
44+
{
45+
"line": 3,
46+
"col": 1
47+
},
48+
{
49+
"line": 3,
50+
"col": 14
51+
}
52+
]
53+
},
54+
{
55+
"name": "indexterm",
56+
"type": "inline",
57+
"term": "Arthur",
58+
"visible": true,
59+
"location": [
60+
{
61+
"line": 3,
62+
"col": 15
63+
},
64+
{
65+
"line": 3,
66+
"col": 24
67+
}
68+
]
69+
},
70+
{
71+
"name": "text",
72+
"type": "string",
73+
"value": " the king.",
74+
"location": [
75+
{
76+
"line": 3,
77+
"col": 25
78+
},
79+
{
80+
"line": 3,
81+
"col": 34
82+
}
83+
]
84+
}
85+
],
86+
"location": [
87+
{
88+
"line": 3,
89+
"col": 1
90+
},
91+
{
92+
"line": 3,
93+
"col": 34
94+
}
95+
]
96+
},
97+
{
98+
"name": "paragraph",
99+
"type": "block",
100+
"inlines": [
101+
{
102+
"name": "indexterm",
103+
"type": "inline",
104+
"term": "Sword",
105+
"secondary": "Broadsword",
106+
"visible": false,
107+
"location": [
108+
{
109+
"line": 5,
110+
"col": 1
111+
},
112+
{
113+
"line": 5,
114+
"col": 23
115+
}
116+
]
117+
},
118+
{
119+
"name": "text",
120+
"type": "string",
121+
"value": "A concealed term for swords.",
122+
"location": [
123+
{
124+
"line": 5,
125+
"col": 24
126+
},
127+
{
128+
"line": 5,
129+
"col": 51
130+
}
131+
]
132+
}
133+
],
134+
"location": [
135+
{
136+
"line": 5,
137+
"col": 1
138+
},
139+
{
140+
"line": 5,
141+
"col": 51
142+
}
143+
]
144+
},
145+
{
146+
"name": "paragraph",
147+
"type": "block",
148+
"inlines": [
149+
{
150+
"name": "text",
151+
"type": "string",
152+
"value": "Using macro style: ",
153+
"location": [
154+
{
155+
"line": 7,
156+
"col": 1
157+
},
158+
{
159+
"line": 7,
160+
"col": 19
161+
}
162+
]
163+
},
164+
{
165+
"name": "indexterm",
166+
"type": "inline",
167+
"term": "Excalibur",
168+
"visible": true,
169+
"location": [
170+
{
171+
"line": 7,
172+
"col": 20
173+
},
174+
{
175+
"line": 7,
176+
"col": 41
177+
}
178+
]
179+
},
180+
{
181+
"name": "text",
182+
"type": "string",
183+
"value": ".",
184+
"location": [
185+
{
186+
"line": 7,
187+
"col": 42
188+
},
189+
{
190+
"line": 7,
191+
"col": 42
192+
}
193+
]
194+
}
195+
],
196+
"location": [
197+
{
198+
"line": 7,
199+
"col": 1
200+
},
201+
{
202+
"line": 7,
203+
"col": 42
204+
}
205+
]
206+
},
207+
{
208+
"name": "paragraph",
209+
"type": "block",
210+
"inlines": [
211+
{
212+
"name": "text",
213+
"type": "string",
214+
"value": "And concealed macro: ",
215+
"location": [
216+
{
217+
"line": 9,
218+
"col": 1
219+
},
220+
{
221+
"line": 9,
222+
"col": 21
223+
}
224+
]
225+
},
226+
{
227+
"name": "indexterm",
228+
"type": "inline",
229+
"term": "Knights",
230+
"secondary": "Round Table",
231+
"visible": false,
232+
"location": [
233+
{
234+
"line": 9,
235+
"col": 22
236+
},
237+
{
238+
"line": 9,
239+
"col": 53
240+
}
241+
]
242+
},
243+
{
244+
"name": "text",
245+
"type": "string",
246+
"value": ".",
247+
"location": [
248+
{
249+
"line": 9,
250+
"col": 54
251+
},
252+
{
253+
"line": 9,
254+
"col": 54
255+
}
256+
]
257+
}
258+
],
259+
"location": [
260+
{
261+
"line": 9,
262+
"col": 1
263+
},
264+
{
265+
"line": 9,
266+
"col": 54
267+
}
268+
]
269+
}
270+
],
271+
"location": [
272+
{
273+
"line": 1,
274+
"col": 1
275+
},
276+
{
277+
"line": 9,
278+
"col": 54
279+
}
280+
]
281+
}

0 commit comments

Comments
 (0)