changed: read glossary from YAML file
Gitea Action for checking typst compilation / run-ci-linux (push) Successful in 28s Details

This commit is contained in:
Sven Vogel 2024-07-08 14:25:56 +02:00
parent 5ea73081a6
commit c06fecec4c
5 changed files with 74 additions and 20 deletions

60
src/glossary.typ Normal file
View File

@ -0,0 +1,60 @@
// .--------------------------------------------------------------------------.
// | Glossary Utilities |
// '--------------------------------------------------------------------------'
// Author: Sven Vogel
// Edited: 08.07.2024
// License: MIT
#let glossary(entries) = {
assert(
type(entries) == dictionary,
message: "The glossary is not a dictionary",
)
for (k, v) in entries.pairs() {
assert(
type(v) == dictionary,
message: "The glossary entry `" + k + "` is not a dictionary")
for key in v.keys() {
assert(
key in ("short", "long", "desc", "group"),
message: "Found unexpected key `" + key + "` in glossary entry `" + k)
}
assert(
type(v.short) == str,
message: "The short form of glossary entry `" + k + "` is not a string")
if "long" in v {
assert(
type(v.long) == str,
message: "The long form of glossary entry `" + k + "` is not a string")
}
if "desc" in v {
assert(
type(v.desc) == str,
message: "The description of glossary entry `" + k + "` is not a string")
}
if "group" in v {
assert(
type(v.group) == str,
message: "The optional group of glossary entry `" + k + "` is not a string")
} else {
panic("Missing group for glossary entry: `" + k + "`")
}
}
return entries.pairs().map(((key, entry)) => (
key: key,
short: eval(entry.short, mode: "markup"),
long: eval(entry.at("long", default: ""), mode: "markup"),
desc: eval(entry.at("desc", default: ""), mode: "markup"),
group: entry.at("group", default: "")
))
}

View File

@ -10,6 +10,7 @@
#import "conf.typ": validate-config #import "conf.typ": validate-config
#import "branding.typ": * #import "branding.typ": *
#import "style.typ": global_styled_doc, content_styled, end_styled #import "style.typ": global_styled_doc, content_styled, end_styled
#import "glossary.typ": glossary
#import "pages/titlepage.typ": new_title_page #import "pages/titlepage.typ": new_title_page
#import "pages/declaration-of-authorship.typ": new_declaration_of_authorship #import "pages/declaration-of-authorship.typ": new_declaration_of_authorship
#import "pages/confidentiality-statement.typ": new_confidentiality_statement_page #import "pages/confidentiality-statement.typ": new_confidentiality_statement_page
@ -67,7 +68,7 @@
print-glossary( print-glossary(
disable-back-references: true, disable-back-references: true,
enable-group-pagebreak: true, enable-group-pagebreak: true,
config.thesis.glossary) glossary(config.thesis.glossary))
pagebreak(weak: true) pagebreak(weak: true)
} }

View File

@ -1,17 +0,0 @@
#let glossary = (
(
key: "oidc",
short: "OIDC",
long: "OpenID Connect",
desc: [OpenID is an open standard and decentralized authentication protocol promoted by the non-profit #link("https://en.wikipedia.org/wiki/OpenID#OpenID_Foundation")[OpenID Foundation].],
group: "Akronyme"
),
(
key: "potato",
short: "EDDI/EDDP",
plural: "potatoes",
desc: [#lorem(10)],
group: "Akronyme"
)
)

11
template/glossary.yml Normal file
View File

@ -0,0 +1,11 @@
oidc:
short: OIDC
long: OpenID Connect
desc: "OpenID is an open standard and decentralized authentication protocol promoted by the non-profit #link(\"https://en.wikipedia.org/wiki/OpenID#OpenID_Foundation\")[OpenID Foundation]."
group: Acronym
potato:
short: potato
desc: "#lorem(50)"
group: Acronym

View File

@ -1,6 +1,5 @@
#import "../src/lib.typ": * #import "../src/lib.typ": *
#import "glossary.typ": glossary
#import "abstract.typ": abstract, summary #import "abstract.typ": abstract, summary
#show: dhbw-template.with(( #show: dhbw-template.with((
@ -27,7 +26,7 @@
preface: include "preface.typ", preface: include "preface.typ",
keywords: ( "IT", "other stuff" ), keywords: ( "IT", "other stuff" ),
bibliography: bibliography("refs.bib"), bibliography: bibliography("refs.bib"),
glossary: glossary, glossary: yaml("glossary.yml"),
appendices: include "appendix.typ"))) appendices: include "appendix.typ")))
#import "@preview/wrap-it:0.1.0": wrap-content #import "@preview/wrap-it:0.1.0": wrap-content