Skip to content

Commit c477f19

Browse files
committed
Error message when capitalizing content
1 parent b89f6c2 commit c477f19

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

themes/default.typ

+9-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#let __glossary_is_empty = "glossary_is_empty"
4242
#let __entry_has_neither_short_nor_long = "entry_has_neither_short_nor_long"
4343
#let __make_glossary_not_called = "make_glossary_not_called"
44+
#let __capitalize_called_with_content_type = "__capitalize_called_with_content_type"
4445
#let __unknown_error = "unknown_error"
4546

4647
// __error_message(key, kind, ..kwargs) -> str
@@ -67,6 +68,10 @@
6768
msg = "entry '" + key + "' has neither short nor long form"
6869
} else if kind == __glossary_is_empty {
6970
msg = "glossary is empty. Use `register-glossary(entry-list)` immediately after `make-glossary`."
71+
} else if kind == __capitalize_called_with_content_type {
72+
msg = (
73+
"Capitalization was requested for " + key + ", but short or long is of type content. Use a string instead."
74+
)
7075
} else if kind == __make_glossary_not_called {
7176
msg = "make-glossary not called. Add `#show: make-glossary` at the beginning of the document."
7277
} else {
@@ -77,8 +82,11 @@
7782
return __glossarium_error_prefix + msg
7883
}
7984

80-
#let __capitalize(text: "") = {
85+
#let __capitalize(text) = {
8186
if text == "" { return text }
87+
if type(text) == content {
88+
panic(__error_message(key, __capitalize_called_with_content_type))
89+
}
8290
return upper(text.first()) + text.slice(1)
8391
}
8492

0 commit comments

Comments
 (0)