fix(documentary): normalize thesis title before rendering documentary page #2

This commit is contained in:
2026-03-16 16:51:27 +02:00
parent a67fe5623a
commit 4c5b829df2
3 changed files with 30 additions and 21 deletions

View File

@@ -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( #let make-documentary-page(
title, title,
authors, authors,
@@ -137,11 +163,11 @@
presentation-date, presentation-date,
) = { ) = {
set page(numbering: none) set page(numbering: none)
heading(level: 1, outlined: false, numbering: none, "Dokumentārā lapa")
set par(spacing: 2em) set par(spacing: 2em)
heading(level: 1, outlined: false, numbering: none, "Dokumentārā lapa")
make-dokumentary( make-dokumentary(
title, normalize-title(title),
authors, authors,
advisors, advisors,
reviewer, reviewer,
@@ -150,3 +176,4 @@
fmt-date(presentation-date), fmt-date(presentation-date),
) )
} }

View File

@@ -293,26 +293,9 @@
make-attachments(attachment-title, attachments) 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 { if display-documentary {
make-documentary-page( make-documentary-page(
title-text, title,
authors, authors,
advisors, advisors,
reviewer, reviewer,

View File

@@ -1,6 +1,5 @@
#import "documentary-page.typ": get-thesis-label, make-documentary-page #import "documentary-page.typ": get-thesis-label, make-documentary-page
#let merge(a, b) = { #let merge(a, b) = {
let result = a let result = a
for (k, v) in b { result.at(k) = v } for (k, v) in b { result.at(k) = v }