Skip to content

Commit 6c5f6f3

Browse files
committed
feat(typ): add semantic subtree sugar helpers for markdown tags
1 parent cec8d1a commit 6c5f6f3

3 files changed

Lines changed: 330 additions & 3 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ target/
1212

1313
# MSVC Windows builds of rustc generate these, which store debugging information
1414
*.pdb
15+
16+
/AGENTS.md

featured-demo/trees/_lib/kodama.typ

Lines changed: 164 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2025 Kodama Project. All rights reserved.
1+
// Copyright (c) 2025 Kodama Project. All rights reserved.
22
// Released under the GPL-3.0 license as described in the file LICENSE.
33
// Authors: Alias Qli (@AliasQli), Kokic (@kokic)
44
// Last modified time: 2026/03/06
@@ -171,6 +171,168 @@
171171
}
172172
})
173173

174+
// Semantic subtree sugar helpers aligned with markdown subtree tags.
175+
#let exegesis(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
176+
slug: slug,
177+
title: title,
178+
taxon: if taxon == none { "exegesis" } else { taxon },
179+
numbering: numbering,
180+
open: open,
181+
catalog: catalog,
182+
content,
183+
)
184+
185+
#let definition(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
186+
slug: slug,
187+
title: title,
188+
taxon: if taxon == none { "definition" } else { taxon },
189+
numbering: numbering,
190+
open: open,
191+
catalog: catalog,
192+
content,
193+
)
194+
195+
#let proposition(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
196+
slug: slug,
197+
title: title,
198+
taxon: if taxon == none { "proposition" } else { taxon },
199+
numbering: numbering,
200+
open: open,
201+
catalog: catalog,
202+
content,
203+
)
204+
205+
#let remark(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
206+
slug: slug,
207+
title: title,
208+
taxon: if taxon == none { "remark" } else { taxon },
209+
numbering: numbering,
210+
open: open,
211+
catalog: catalog,
212+
content,
213+
)
214+
215+
#let conjecture(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
216+
slug: slug,
217+
title: title,
218+
taxon: if taxon == none { "conjecture" } else { taxon },
219+
numbering: numbering,
220+
open: open,
221+
catalog: catalog,
222+
content,
223+
)
224+
225+
#let postulate(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
226+
slug: slug,
227+
title: title,
228+
taxon: if taxon == none { "postulate" } else { taxon },
229+
numbering: numbering,
230+
open: open,
231+
catalog: catalog,
232+
content,
233+
)
234+
235+
#let claim(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
236+
slug: slug,
237+
title: title,
238+
taxon: if taxon == none { "claim" } else { taxon },
239+
numbering: numbering,
240+
open: open,
241+
catalog: catalog,
242+
content,
243+
)
244+
245+
#let observation(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
246+
slug: slug,
247+
title: title,
248+
taxon: if taxon == none { "observation" } else { taxon },
249+
numbering: numbering,
250+
open: open,
251+
catalog: catalog,
252+
content,
253+
)
254+
255+
#let fact(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
256+
slug: slug,
257+
title: title,
258+
taxon: if taxon == none { "fact" } else { taxon },
259+
numbering: numbering,
260+
open: open,
261+
catalog: catalog,
262+
content,
263+
)
264+
265+
#let hypothesis(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
266+
slug: slug,
267+
title: title,
268+
taxon: if taxon == none { "hypothesis" } else { taxon },
269+
numbering: numbering,
270+
open: open,
271+
catalog: catalog,
272+
content,
273+
)
274+
275+
#let axiom(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
276+
slug: slug,
277+
title: title,
278+
taxon: if taxon == none { "axiom" } else { taxon },
279+
numbering: numbering,
280+
open: open,
281+
catalog: catalog,
282+
content,
283+
)
284+
285+
#let lemma(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
286+
slug: slug,
287+
title: title,
288+
taxon: if taxon == none { "lemma" } else { taxon },
289+
numbering: numbering,
290+
open: open,
291+
catalog: catalog,
292+
content,
293+
)
294+
295+
#let theorem(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
296+
slug: slug,
297+
title: title,
298+
taxon: if taxon == none { "theorem" } else { taxon },
299+
numbering: numbering,
300+
open: open,
301+
catalog: catalog,
302+
content,
303+
)
304+
305+
#let corollary(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
306+
slug: slug,
307+
title: title,
308+
taxon: if taxon == none { "corollary" } else { taxon },
309+
numbering: numbering,
310+
open: open,
311+
catalog: catalog,
312+
content,
313+
)
314+
315+
#let example(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
316+
slug: slug,
317+
title: title,
318+
taxon: if taxon == none { "example" } else { taxon },
319+
numbering: numbering,
320+
open: open,
321+
catalog: catalog,
322+
content,
323+
)
324+
325+
#let proof(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
326+
slug: slug,
327+
title: title,
328+
taxon: if taxon == none { "proof" } else { taxon },
329+
numbering: numbering,
330+
open: open,
331+
catalog: catalog,
332+
content,
333+
)
334+
335+
174336
/**
175337
* HTML: SVG formula rendering vertical position adjustment
176338
*/
@@ -248,3 +410,4 @@
248410
},
249411
)
250412
}
413+

src/include/kodama.typ

Lines changed: 164 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Copyright (c) 2025 Kodama Project. All rights reserved.
1+
// Copyright (c) 2025 Kodama Project. All rights reserved.
22
// Released under the GPL-3.0 license as described in the file LICENSE.
33
// Authors: Alias Qli (@AliasQli), Kokic (@kokic)
4-
// Last modified time: 2026/02/28
4+
// Last modified time: 2026/03/06
55

66
/**
77
* There are some external inputs:
@@ -171,6 +171,167 @@
171171
}
172172
})
173173

174+
// Semantic subtree sugar helpers aligned with markdown subtree tags.
175+
#let exegesis(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
176+
slug: slug,
177+
title: title,
178+
taxon: if taxon == none { "exegesis" } else { taxon },
179+
numbering: numbering,
180+
open: open,
181+
catalog: catalog,
182+
content,
183+
)
184+
185+
#let definition(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
186+
slug: slug,
187+
title: title,
188+
taxon: if taxon == none { "definition" } else { taxon },
189+
numbering: numbering,
190+
open: open,
191+
catalog: catalog,
192+
content,
193+
)
194+
195+
#let proposition(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
196+
slug: slug,
197+
title: title,
198+
taxon: if taxon == none { "proposition" } else { taxon },
199+
numbering: numbering,
200+
open: open,
201+
catalog: catalog,
202+
content,
203+
)
204+
205+
#let remark(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
206+
slug: slug,
207+
title: title,
208+
taxon: if taxon == none { "remark" } else { taxon },
209+
numbering: numbering,
210+
open: open,
211+
catalog: catalog,
212+
content,
213+
)
214+
215+
#let conjecture(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
216+
slug: slug,
217+
title: title,
218+
taxon: if taxon == none { "conjecture" } else { taxon },
219+
numbering: numbering,
220+
open: open,
221+
catalog: catalog,
222+
content,
223+
)
224+
225+
#let postulate(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
226+
slug: slug,
227+
title: title,
228+
taxon: if taxon == none { "postulate" } else { taxon },
229+
numbering: numbering,
230+
open: open,
231+
catalog: catalog,
232+
content,
233+
)
234+
235+
#let claim(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
236+
slug: slug,
237+
title: title,
238+
taxon: if taxon == none { "claim" } else { taxon },
239+
numbering: numbering,
240+
open: open,
241+
catalog: catalog,
242+
content,
243+
)
244+
245+
#let observation(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
246+
slug: slug,
247+
title: title,
248+
taxon: if taxon == none { "observation" } else { taxon },
249+
numbering: numbering,
250+
open: open,
251+
catalog: catalog,
252+
content,
253+
)
254+
255+
#let fact(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
256+
slug: slug,
257+
title: title,
258+
taxon: if taxon == none { "fact" } else { taxon },
259+
numbering: numbering,
260+
open: open,
261+
catalog: catalog,
262+
content,
263+
)
264+
265+
#let hypothesis(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
266+
slug: slug,
267+
title: title,
268+
taxon: if taxon == none { "hypothesis" } else { taxon },
269+
numbering: numbering,
270+
open: open,
271+
catalog: catalog,
272+
content,
273+
)
274+
275+
#let axiom(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
276+
slug: slug,
277+
title: title,
278+
taxon: if taxon == none { "axiom" } else { taxon },
279+
numbering: numbering,
280+
open: open,
281+
catalog: catalog,
282+
content,
283+
)
284+
285+
#let lemma(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
286+
slug: slug,
287+
title: title,
288+
taxon: if taxon == none { "lemma" } else { taxon },
289+
numbering: numbering,
290+
open: open,
291+
catalog: catalog,
292+
content,
293+
)
294+
295+
#let theorem(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
296+
slug: slug,
297+
title: title,
298+
taxon: if taxon == none { "theorem" } else { taxon },
299+
numbering: numbering,
300+
open: open,
301+
catalog: catalog,
302+
content,
303+
)
304+
305+
#let corollary(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
306+
slug: slug,
307+
title: title,
308+
taxon: if taxon == none { "corollary" } else { taxon },
309+
numbering: numbering,
310+
open: open,
311+
catalog: catalog,
312+
content,
313+
)
314+
315+
#let example(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
316+
slug: slug,
317+
title: title,
318+
taxon: if taxon == none { "example" } else { taxon },
319+
numbering: numbering,
320+
open: open,
321+
catalog: catalog,
322+
content,
323+
)
324+
325+
#let proof(slug: none, title: none, taxon: none, numbering: false, open: true, catalog: true, content) = subtree(
326+
slug: slug,
327+
title: title,
328+
taxon: if taxon == none { "proof" } else { taxon },
329+
numbering: numbering,
330+
open: open,
331+
catalog: catalog,
332+
content,
333+
)
334+
174335

175336
/**
176337
* HTML: SVG formula rendering vertical position adjustment
@@ -249,3 +410,4 @@
249410
},
250411
)
251412
}
413+

0 commit comments

Comments
 (0)