diff --git a/src/documentary-page.typ b/src/documentary-page.typ index 13b1f68..a13c5f4 100644 --- a/src/documentary-page.typ +++ b/src/documentary-page.typ @@ -127,6 +127,32 @@ ] } +#let normalize-title(title) = { + if type(title) != content or "children" not in title.fields() { + return title + } + + let children = title + .fields() + .children + .filter(it => it.func() != linebreak) + .fold((), (acc, it) => { + if it == [ ] and (acc.len() == 0 or acc.last() == [ ]) { + acc + } else { + acc + (it,) + } + }) + + let children = if children.len() > 0 and children.last() == [ ] { + children.slice(0, -1) + } else { + children + } + + children.join("") +} + #let make-documentary-page( title, authors, @@ -137,11 +163,11 @@ presentation-date, ) = { set page(numbering: none) - heading(level: 1, outlined: false, numbering: none, "Dokumentārā lapa") set par(spacing: 2em) + heading(level: 1, outlined: false, numbering: none, "Dokumentārā lapa") make-dokumentary( - title, + normalize-title(title), authors, advisors, reviewer, @@ -150,3 +176,4 @@ fmt-date(presentation-date), ) } + diff --git a/src/lib.typ b/src/lib.typ index e24e717..d770f76 100644 --- a/src/lib.typ +++ b/src/lib.typ @@ -293,26 +293,9 @@ make-attachments(attachment-title, attachments) - let title-text = if type(title) == content and "children" in title.fields() { - title - .fields() - .children - .filter(it => it.func() != linebreak) - .fold((), (acc, it) => { - if it == [ ] and acc.len() > 0 and acc.last() == [ ] { - acc - } else { - acc + (it,) - } - }) - .join("") - } else { - title - } - if display-documentary { make-documentary-page( - title-text, + title, authors, advisors, reviewer, diff --git a/src/utils.typ b/src/utils.typ index 016cfd9..1c5e062 100644 --- a/src/utils.typ +++ b/src/utils.typ @@ -1,6 +1,5 @@ #import "documentary-page.typ": get-thesis-label, make-documentary-page - #let merge(a, b) = { let result = a for (k, v) in b { result.at(k) = v }