Skip to content

Commit

Permalink
delegis:0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka authored May 15, 2024
1 parent 2670de9 commit f8c955d
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 41 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ Sie kann jederzeit gekündigt werden.
Die Ehrenmitgliedschaft wird durch den Vorstand verliehen.
```

Alternatively (or if you want to use special characters otherwise not supported, such as `*`), you can also use the `#section[number][title]` function:

```typst
#section[§ 3][Administrator*innen]
```

### Overarching Sections

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:
Expand Down Expand Up @@ -102,3 +108,24 @@ In some cases, referencing sections using `§ X` could be mis-interpreted as a n
Diese Ordnung tritt am 24.01.2024 in Kraft. §~4 bleibt unberührt.
```

## Changelog

### v0.2.0

#### Features
- 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:
- `<title>`
- `<abbreviation>`
- `<resolution>`
- `<in-effect>`
- 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.
- 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.
- Set the footnote numbering to `[1]` to not collide with sentence numbers.
#### Bug Fixes
- Fix a typo in the `str-draft` variable name that lead to draft documents resulting in a syntax error.
- Fix hyphenation issues with the abbreviation on the title page (hyphenation between the parentheses and the abbreviation itself)

### v0.1.0

Initial Release
102 changes: 62 additions & 40 deletions delegis.typ
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
// sentence marker
#let s = "XXXXXX"
// sentence number substitution marker
#let s = "XXXXXXSENTENCEXXXNUMBERXXXXXX"

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

// template
/// Manually create a section. Useful when unsupported characters are used in the heading.
/// Usage: `#section[§ 3][Administrator*innen]`
#let section = (number, it, ..rest) => unnumbered({number + "\n" + it}, ..rest)

/// Initialize a delegis document.
#let delegis = (
// Metadata
title : "Vereinsordnung zur IT-Infrastruktur",
Expand All @@ -22,80 +28,96 @@
str-intro : (resolution, in-effect) => [Mit Beschluss (#resolution) tritt zum #in-effect in Kraft:],
// Content
body
) => [
/// General Formatting
#set document(title: title + " (" + abbreviation + ")", keywords: (title, abbreviation, resolution, in-effect))
) => {
/// Metadata
set document(title: title + " (" + abbreviation + ")", keywords: (title, abbreviation, resolution, in-effect))

#let bg = if draft {
rotate(45deg, text(100pt, fill: luma(85%), font: font, strDraft))
/// General Formatting
let bg = if draft {
rotate(45deg, text(100pt, fill: luma(85%), font: font, str-draft))
} else {}

#set page(paper: paper, numbering: "1 / 1", background: bg)
#set text(hyphenate: true, lang: lang, size: size, font: font)
set page(paper: paper, numbering: "1 / 1", background: bg)
set text(hyphenate: true, lang: lang, size: size, font: font)

/// Clause Detection
#show regex("§ ([0-9a-zA-Z]+) (.+)$"): it => {

show regex("§ ([0-9a-zA-Z]+) (.+)$"): it => {
let (_, number, ..rest) = it.text.split()


align(center, heading(level: 6, numbering: none, {
heading(level: 6, numbering: none, {
"§ " + number + "\n" + rest.join(" ")
}))
})
}

/// Heading Formatting
#set heading(numbering: "I.1.A.i.a.")
#show heading: it => {
set align(center)

text(size: size, it, weight: "regular")
}
set heading(numbering: "I.1.A.i.a.")
show heading: set align(center)
show heading: set text(size: size, weight: "regular")

#show heading.where(level: 1): it => emph(it)
#show heading.where(level: 2): it => emph(it)
#show heading.where(level: 3): it => emph(it)
#show heading.where(level: 4): it => emph(it)
#show heading.where(level: 5): it => emph(it)

#show heading.where(level: 6): it => strong(it)
show heading.where(level: 1): set text(style: "italic")
show heading.where(level: 2): set text(style: "italic")
show heading.where(level: 3): set text(style: "italic")
show heading.where(level: 4): set text(style: "italic")
show heading.where(level: 5): set text(style: "italic")

show heading.where(level: 6): set text(weight: "bold")

/// Outlines
#show outline.entry: it => {
show linebreak: it => {}
show "\n": " "
show outline.entry: it => {
show linebreak: it => {} // disable manual line breaks
show "\n": " " // disable section number line breaks
it
}

#set outline(indent: 1cm)
#show outline: it => {
set outline(indent: 1cm)
show outline: it => {
it
pagebreak(weak: true)
}

/// Sentence Numbering
#show regex("XXXXXX"): it => {
show regex(s): it => {
counter("sentence").step()
super(strong(counter("sentence").display()))
}

#show parbreak: it => {
show parbreak: it => {
counter("sentence").update(0)
it
}

/// Title Page
#page(numbering: none,{
page(numbering: none, {
place(top + right, block(width: 2cm, logo))
v(1fr)

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

if draft { text[#str-draft:] } else { par(text(str-intro(resolution, in-effect))) }
par(text(2em, strong[#title~(#abbreviation)]), leading: 0.6em)
if draft {
text[#str-draft:]
} else {
par(text(str-intro(resolution, in-effect)))
}

par(text(2em, strong[#title (#abbreviation)]), leading: 0.6em)

v(3cm)
})

// Metadata once again. Needs to be down here to have the page size set.
// Can be used with `typst query`, e.g.:
//
// `typst query example.typ "<title>" --field value --one` returns `"[title]"`
[
#metadata(title)<title>
#metadata(abbreviation)<abbreviation>
#metadata(resolution)<resolution>
#metadata(in-effect)<in-effect>
]

// allow footnotes that don't conflict with sentence numbers
set footnote(numbering: "[1]")

/// Content
#body
]
body
}
4 changes: 4 additions & 0 deletions template/main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ Fußnoten dienen als redaktionelle Anmerkungen oder Interpretationshilfen und si
(2)
#s~#lorem(3)
#s~#lorem(8)

#section[§ 3][Administrator*innen]

#lorem(30)
2 changes: 1 addition & 1 deletion typst.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "delegis"
version = "0.1.0"
version = "0.2.0"
entrypoint = "delegis.typ"
authors = ["WüSpace e. V. <https://github.com/wuespace>"]
repository = "https://github.com/wuespace/delegis"
Expand Down

0 comments on commit f8c955d

Please sign in to comment.