Skip to content

Commit f8c955d

Browse files
authored
delegis:0.2.0
1 parent 2670de9 commit f8c955d

File tree

4 files changed

+94
-41
lines changed

4 files changed

+94
-41
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ Sie kann jederzeit gekündigt werden.
6060
Die Ehrenmitgliedschaft wird durch den Vorstand verliehen.
6161
```
6262

63+
Alternatively (or if you want to use special characters otherwise not supported, such as `*`), you can also use the `#section[number][title]` function:
64+
65+
```typst
66+
#section[§ 3][Administrator*innen]
67+
```
68+
6369
### Overarching Sections
6470

6571
If you want to add more structure to your sections, you can use normal Typst headings. Note that only the level 6 headings are reserved for the section numbers:
@@ -102,3 +108,24 @@ In some cases, referencing sections using `§ X` could be mis-interpreted as a n
102108
103109
Diese Ordnung tritt am 24.01.2024 in Kraft. §~4 bleibt unberührt.
104110
```
111+
112+
## Changelog
113+
114+
### v0.2.0
115+
116+
#### Features
117+
- Add `#metadata` fields for usage with `typst query`. You can now use `typst query file.typ "<field>" --field value --one` with `<field>` being one of the following to query metadata fields in the command line:
118+
- `<title>`
119+
- `<abbreviation>`
120+
- `<resolution>`
121+
- `<in-effect>`
122+
- Add `#section[§ 1][ABC]` function to enable previously unsupported special chars (such as `*`) in section headings. Note that this was previously possible using `#unnumbered[§ 1\ ABC]`, but the new function adds a semantically better-fitting alternative to this fix.
123+
- Improve heading style rules. This also fixes an incompatibility with `pandoc`, meaning it's now possible to use `pandoc` to convert delegis documents to HTML, etc.
124+
- Set the footnote numbering to `[1]` to not collide with sentence numbers.
125+
#### Bug Fixes
126+
- Fix a typo in the `str-draft` variable name that lead to draft documents resulting in a syntax error.
127+
- Fix hyphenation issues with the abbreviation on the title page (hyphenation between the parentheses and the abbreviation itself)
128+
129+
### v0.1.0
130+
131+
Initial Release

delegis.typ

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
// sentence marker
2-
#let s = "XXXXXX"
1+
// sentence number substitution marker
2+
#let s = "XXXXXXSENTENCEXXXNUMBERXXXXXX"
33

4+
/// Create an unmarkes section, such as a preamble.
5+
/// Usage: `#unnumbered[Preamble]`
46
#let unnumbered = (it, ..rest) => heading(level: 6, numbering: none, ..rest, it)
57

6-
// template
8+
/// Manually create a section. Useful when unsupported characters are used in the heading.
9+
/// Usage: `#section[§ 3][Administrator*innen]`
10+
#let section = (number, it, ..rest) => unnumbered({number + "\n" + it}, ..rest)
11+
12+
/// Initialize a delegis document.
713
#let delegis = (
814
// Metadata
915
title : "Vereinsordnung zur IT-Infrastruktur",
@@ -22,80 +28,96 @@
2228
str-intro : (resolution, in-effect) => [Mit Beschluss (#resolution) tritt zum #in-effect in Kraft:],
2329
// Content
2430
body
25-
) => [
26-
/// General Formatting
27-
#set document(title: title + " (" + abbreviation + ")", keywords: (title, abbreviation, resolution, in-effect))
31+
) => {
32+
/// Metadata
33+
set document(title: title + " (" + abbreviation + ")", keywords: (title, abbreviation, resolution, in-effect))
2834

29-
#let bg = if draft {
30-
rotate(45deg, text(100pt, fill: luma(85%), font: font, strDraft))
35+
/// General Formatting
36+
let bg = if draft {
37+
rotate(45deg, text(100pt, fill: luma(85%), font: font, str-draft))
3138
} else {}
3239

33-
#set page(paper: paper, numbering: "1 / 1", background: bg)
34-
#set text(hyphenate: true, lang: lang, size: size, font: font)
40+
set page(paper: paper, numbering: "1 / 1", background: bg)
41+
set text(hyphenate: true, lang: lang, size: size, font: font)
3542

3643
/// Clause Detection
37-
#show regex("§ ([0-9a-zA-Z]+) (.+)$"): it => {
38-
44+
show regex("§ ([0-9a-zA-Z]+) (.+)$"): it => {
3945
let (_, number, ..rest) = it.text.split()
4046

41-
42-
align(center, heading(level: 6, numbering: none, {
47+
heading(level: 6, numbering: none, {
4348
"§ " + number + "\n" + rest.join(" ")
44-
}))
49+
})
4550
}
4651

4752
/// Heading Formatting
48-
#set heading(numbering: "I.1.A.i.a.")
49-
#show heading: it => {
50-
set align(center)
51-
52-
text(size: size, it, weight: "regular")
53-
}
53+
set heading(numbering: "I.1.A.i.a.")
54+
show heading: set align(center)
55+
show heading: set text(size: size, weight: "regular")
5456

55-
#show heading.where(level: 1): it => emph(it)
56-
#show heading.where(level: 2): it => emph(it)
57-
#show heading.where(level: 3): it => emph(it)
58-
#show heading.where(level: 4): it => emph(it)
59-
#show heading.where(level: 5): it => emph(it)
60-
61-
#show heading.where(level: 6): it => strong(it)
57+
show heading.where(level: 1): set text(style: "italic")
58+
show heading.where(level: 2): set text(style: "italic")
59+
show heading.where(level: 3): set text(style: "italic")
60+
show heading.where(level: 4): set text(style: "italic")
61+
show heading.where(level: 5): set text(style: "italic")
6262

63+
show heading.where(level: 6): set text(weight: "bold")
64+
6365
/// Outlines
64-
#show outline.entry: it => {
65-
show linebreak: it => {}
66-
show "\n": " "
66+
show outline.entry: it => {
67+
show linebreak: it => {} // disable manual line breaks
68+
show "\n": " " // disable section number line breaks
6769
it
6870
}
6971

70-
#set outline(indent: 1cm)
71-
#show outline: it => {
72+
set outline(indent: 1cm)
73+
show outline: it => {
7274
it
7375
pagebreak(weak: true)
7476
}
7577

7678
/// Sentence Numbering
77-
#show regex("XXXXXX"): it => {
79+
show regex(s): it => {
7880
counter("sentence").step()
7981
super(strong(counter("sentence").display()))
8082
}
8183

82-
#show parbreak: it => {
84+
show parbreak: it => {
8385
counter("sentence").update(0)
8486
it
8587
}
8688

8789
/// Title Page
88-
#page(numbering: none,{
90+
page(numbering: none, {
8991
place(top + right, block(width: 2cm, logo))
9092
v(1fr)
9193

9294
show par: set block(spacing: .6em)
9395

94-
if draft { text[#str-draft:] } else { par(text(str-intro(resolution, in-effect))) }
95-
par(text(2em, strong[#title~(#abbreviation)]), leading: 0.6em)
96+
if draft {
97+
text[#str-draft:]
98+
} else {
99+
par(text(str-intro(resolution, in-effect)))
100+
}
101+
102+
par(text(2em, strong[#title (#abbreviation)]), leading: 0.6em)
103+
96104
v(3cm)
97105
})
98106

107+
// Metadata once again. Needs to be down here to have the page size set.
108+
// Can be used with `typst query`, e.g.:
109+
//
110+
// `typst query example.typ "<title>" --field value --one` returns `"[title]"`
111+
[
112+
#metadata(title)<title>
113+
#metadata(abbreviation)<abbreviation>
114+
#metadata(resolution)<resolution>
115+
#metadata(in-effect)<in-effect>
116+
]
117+
118+
// allow footnotes that don't conflict with sentence numbers
119+
set footnote(numbering: "[1]")
120+
99121
/// Content
100-
#body
101-
]
122+
body
123+
}

template/main.typ

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ Fußnoten dienen als redaktionelle Anmerkungen oder Interpretationshilfen und si
5858
(2)
5959
#s~#lorem(3)
6060
#s~#lorem(8)
61+
62+
#section[§ 3][Administrator*innen]
63+
64+
#lorem(30)

typst.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "delegis"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
entrypoint = "delegis.typ"
55
authors = ["WüSpace e. V. <https://github.com/wuespace>"]
66
repository = "https://github.com/wuespace/delegis"

0 commit comments

Comments
 (0)