changed glossarium format
Gitea Action for checking typst compilation / run-ci-linux (push) Successful in 31s Details

This commit is contained in:
Sven Vogel 2024-08-14 11:57:27 +02:00
parent b1aca1b18b
commit 418992d27f
5 changed files with 51 additions and 34 deletions

View File

@ -171,22 +171,21 @@ SOFTWARE.*/
caption: {
context {
let term_references = __query_labels_with_key(here(), entry.key)
if term_references.len() != 0 or show-all {
let desc = entry.at("desc", default: "")
let long = entry.at("long", default: "")
let hasLong = long != "" and long != []
let hasDesc = desc != "" and desc != []
grid(
columns: 2,
column-gutter: 1em,
text(weight: "bold", entry.short),
{
if hasLong {
text(weight: "bold", entry.long)
if term_references.len() != 0 or show-all [
#let desc = entry.at("desc", default: "")
#let long = entry.at("long", default: "")
#let hasLong = long != "" and long != []
#let hasDesc = desc != "" and desc != []
#block(
par(hanging-indent: 1em)[
#text(weight: "bold", entry.short)
#if hasLong {
text(entry.long)
}
if hasLong and hasDesc [:]
if hasDesc [ #desc ] else [. ]
if disable-back-references != true {
#if hasLong and hasDesc [:]
#if hasDesc [ #desc ]
#if disable-back-references != true {
term_references
.map(x => x.location())
.sorted(key: x => x.page())
@ -211,13 +210,12 @@ SOFTWARE.*/
)
.join(", ")
}
},
],
)
}
]
}
},
)[] #label(entry.key)
#parbreak()
]
}
}

View File

@ -14,6 +14,8 @@
message: "The glossary is not a dictionary",
)
let processed_glossary = (:)
for (k, v) in entries.pairs() {
assert(
type(v) == dictionary,
@ -52,27 +54,39 @@
message: "The optional group of glossary entry `" + k + "` is not a string",
)
} else {
let group = if "long" in v {
if (context text.lang) == "de" {
let acronym_group = if (context text.lang) == "de" {
"Akronyme"
} else {
"Acronyms"
}
} else {
if (context text.lang) == "de" {
let glossary_group = if (context text.lang) == "de" {
"Begriffe"
} else {
"Terms"
"Glossary"
}
let group = if "long" in v {
acronym_group
} else {
glossary_group
}
// create dedicated entries for
// acronym and glossary
if "long" in v and "desc" in v {
processed_glossary.insert(k, (short: v.short, long: v.long, group: acronym_group))
processed_glossary.insert(k + "__glossary_entry", (short: v.short, desc: v.desc, group: glossary_group))
} else {
processed_glossary.insert(k, v)
processed_glossary.at(k).group = group
}
}
}
entries.at(k).group = group
}
}
return entries.pairs().map(((key, entry)) => (
return processed_glossary.pairs().map(((key, entry)) => (
key: key,
short: eval(entry.short, mode: "markup"),
short: entry.short,
long: eval(entry.at("long", default: ""), mode: "markup"),
desc: eval(entry.at("desc", default: ""), mode: "markup"),
group: entry.at("group", default: ""),

View File

@ -83,6 +83,7 @@
#if "glossary" in config.thesis and config.thesis.glossary != none {
print-glossary(
show-all: true,
disable-back-references: true,
enable-group-pagebreak: true,
glossary(config.thesis.glossary),

View File

@ -7,3 +7,7 @@ oidc:
potato:
short: potato
desc: "#lorem(50)"
HTTP:
short: HTTP
long: Hyper Text Transfer Protocol

View File

@ -88,7 +88,7 @@ $
#pagebreak()
#lorem(100)
#inline-color("#ff0000", "red")
#inline-color("#ff0000", "red") @HTTP
#figure(
```rust