Merge pull request #6 from rwmpelstilzchen/references

Add reference capability
This commit is contained in:
Greg Shuflin 2024-08-18 22:39:42 -07:00 committed by GitHub
commit 393603ae2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 7 deletions

View File

@ -179,6 +179,20 @@ standard Typst counter functions to control gloss numbering:
translation: [There always is in us a will for a great happiness.],
)", addl-bindings: (gloss-count: gloss-count))
References to individual examples can be achieved using the `label` argument and the referencing mechanism of Typst:
#codeblock(
"See @sorcerers:
#numbered-gloss(
header: [Middle Welsh; modified from _Grammatical number in Welsh_ (1999) by Silva Nurmio (§~2.1.1)],
source: ([ac], [ny], [allvs], [y], [dewinyon], [atteb], [idav]),
morphemes: ([and], [#neg], [be_able.#smallcaps[pret].3#sg], [#smallcaps[def]], [sorcerer.#pl], [answer.#smallcaps[inf]], [to.3#sg.#smallcaps[m]]),
translation: [and the sorcerers could not answer him],
label: \"sorcerers\",
)
As we have seen in @sorcerers, […].", addl-bindings: (neg: neg, sg: sg, pl: pl))
== Styling lines of a gloss

View File

@ -1,6 +1,7 @@
#import "abbreviations.typ"
#let gloss-count = counter("gloss_count")
#let cmdlabel = label // a workround so we can use `label` as a variable name
#let build_gloss(item-spacing, formatters, gloss_line_lists) = {
assert(gloss_line_lists.len() > 0, message: "Gloss line lists cannot be empty")
@ -47,6 +48,7 @@
additional-lines: (), //List of list of content
translation: none,
translation-style: none,
label: none,
item-spacing: 1em,
gloss-padding: 2.0em, //TODO document these
@ -121,13 +123,18 @@
style(styles => {
block(breakable: breakable)[
#stack(
dir:ltr, //TODO this needs to be more flexible
left_padding,
[#gloss_number],
gloss-padding - left_padding - measure([#gloss_number],styles).width,
[#gloss_items]
)
#figure(
kind: "lingexample",
supplement: [Example],
numbering: it => [#gloss-count.display()],
stack(
dir: ltr, //TODO this needs to be more flexible
left_padding,
[#gloss_number],
gloss-padding - left_padding - measure([#gloss_number],styles).width,
align(left)[#gloss_items],
),
) #if label != none {cmdlabel(label)}
]
}
)