Allow morphemes to be none

This commit is contained in:
Greg Shuflin 2023-07-31 02:17:09 -07:00
parent 320f1ad0e5
commit 4dd6d27026
3 changed files with 32 additions and 6 deletions

View File

@ -92,6 +92,28 @@ The `#gloss` function has three pre-defined parameters for glossing levels:
for unaligned text: `header_text` for text that precedes the gloss, and for unaligned text: `header_text` for text that precedes the gloss, and
`translation` for text that follows the gloss. `translation` for text that follows the gloss.
The `morphemes` param can be skipped, if you just want to provide a source
text and translation, without a gloss:
#gloss(
source_text: ([Trato de entender, debo comprender qué es lo que ha hecho conmigo],),
translation: [I try to understand, I should comprehend, what it has done with me],
)
#codeblock[
```typst
#gloss(
source_text: ([Trato de entender, debo comprender qué es lo que ha hecho conmigo],),
translation: [I try to understand, I should comprehend, what it has done with me],
)
```
]
Note that it is still necessary to wrap the `source_text` argument in an array of length one.
If one wishes to add more than three glossing lines, there is an additional If one wishes to add more than three glossing lines, there is an additional
parameter `additional_gloss_lines` that can take a list of arbitrarily many more glossing parameter `additional_gloss_lines` that can take a list of arbitrarily many more glossing
lines, which will appear below those specified in the aforementioned lines, which will appear below those specified in the aforementioned

View File

@ -40,7 +40,7 @@
source_text_style: emph, source_text_style: emph,
transliteration: none, transliteration: none,
transliteration_style: none, transliteration_style: none,
morphemes: (), morphemes: none,
morphemes_style: none, morphemes_style: none,
additional_gloss_lines: (), //List of list of content additional_gloss_lines: (), //List of list of content
translation: none, translation: none,
@ -53,9 +53,11 @@
) = { ) = {
assert(type(source_text) == "array", message: "source_text needs to be an array; perhaps you forgot to type `(` and `)`, or a trailing comma?") assert(type(source_text) == "array", message: "source_text needs to be an array; perhaps you forgot to type `(` and `)`, or a trailing comma?")
assert(type(morphemes) == "array", message: "morphemes needs to be an array; perhaps you forgot to type `(` and `)`, or a trailing comma?")
assert(source_text.len() == morphemes.len(), message: "source_text and morphemes have different lengths") if morphemes != none {
assert(type(morphemes) == "array", message: "morphemes needs to be an array; perhaps you forgot to type `(` and `)`, or a trailing comma?")
assert(source_text.len() == morphemes.len(), message: "source_text and morphemes have different lengths")
}
if transliteration != none { if transliteration != none {
assert(transliteration.len() == source_text.len(), message: "source_text and transliteration have different lengths") assert(transliteration.len() == source_text.len(), message: "source_text and transliteration have different lengths")
@ -80,8 +82,10 @@
gloss_line_lists.push(transliteration) gloss_line_lists.push(transliteration)
} }
formatters.push(morphemes_style) if morphemes != none {
gloss_line_lists.push(morphemes) formatters.push(morphemes_style)
gloss_line_lists.push(morphemes)
}
for additional in additional_gloss_lines { for additional in additional_gloss_lines {
formatters.push(none) //TODO fix this formatters.push(none) //TODO fix this

View File

@ -1,6 +1,6 @@
[package] [package]
name = "leipzig-glossing" name = "leipzig-glossing"
version = "0.1.0" version = "0.1.9"
entrypoint = "leipzig-gloss.typ" entrypoint = "leipzig-gloss.typ"
authors = ["Greg Shuflin", "Other open-source contributors"] authors = ["Greg Shuflin", "Other open-source contributors"]
license = "MIT" license = "MIT"