Change from snake_case to kebab-case in most places

This commit is contained in:
Greg Shuflin 2023-09-19 03:23:50 -07:00
parent 1753717dd8
commit 1eead20457
3 changed files with 82 additions and 82 deletions

Binary file not shown.

View File

@ -56,8 +56,8 @@ As a first example, here is a gloss of a text in Georgian, along with the Typst
#codeblock( #codeblock(
"#gloss( "#gloss(
header_text: [from \"Georgian and the Unaccusative Hypothesis\", Alice Harris, 1982], header: [from \"Georgian and the Unaccusative Hypothesis\", Alice Harris, 1982],
source_text: ([ბავშვ-ი], [ატირდა]), source: ([ბავშვ-ი], [ატირდა]),
transliteration: ([bavšv-i], [aṭirda]), transliteration: ([bavšv-i], [aṭirda]),
morphemes: ([child-#smallcaps[nom]], [3S/cry/#smallcaps[incho]/II]), morphemes: ([child-#smallcaps[nom]], [3S/cry/#smallcaps[incho]/II]),
translation: [The child burst out crying], translation: [The child burst out crying],
@ -69,18 +69,18 @@ for common glossing abbreviations:
#codeblock( #codeblock(
"#gloss( "#gloss(
source_text: ([I'm], [eat-ing], [your], [head]), source: ([I'm], [eat-ing], [your], [head]),
source_text_style: (item) => text(fill: red)[#item], source-style: (item) => text(fill: red)[#item],
morphemes: ([1#sg.#sbj\=to.be], [eat-#prog], [2#sg.#poss], [head]), morphemes: ([1#sg.#sbj\=to.be], [eat-#prog], [2#sg.#poss], [head]),
morphemes_style: text.with(fill: blue), morphemes-style: text.with(fill: blue),
translation: text(weight: \"semibold\")[I'm eating your head!], translation: text(weight: \"semibold\")[I'm eating your head!],
) )
", addl-bindings: (poss: poss, prog: prog, sg: sg, sbj: sbj)) ", addl-bindings: (poss: poss, prog: prog, sg: sg, sbj: sbj))
The `#gloss` function has three pre-defined parameters for glossing levels: The `#gloss` function has three pre-defined parameters for glossing levels:
`source_text`, `transliteration`, and `morphemes`. It also has two parameters `source`, `transliteration`, and `morphemes`. It also has two parameters
for unaligned text: `header_text` for text that precedes the gloss, and for unaligned text: `header` for text that precedes the gloss, and
`translation` for text that follows the gloss. `translation` for text that follows the gloss.
@ -89,27 +89,27 @@ text and translation, without a gloss:
#codeblock( #codeblock(
"#gloss( "#gloss(
source_text: ([Trato de entender, debo comprender, qué es lo que ha hecho conmigo],), source: ([Trato de entender, debo comprender, qué es lo que ha hecho conmigo],),
translation: [I try to understand, I must comprehend, what she has done with me], translation: [I try to understand, I must comprehend, what she has done with me],
) )
") ")
Note that it is still necessary to wrap the `source_text` argument in an array of length one. Note that it is still necessary to wrap the `source` argument in an array of length one.
To add more than three glossing lines, there is an additional parameter 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 `additional-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
parameters: parameters:
#codeblock( #codeblock(
"#gloss( "#gloss(
header_text: [Hunzib (van den Berg 1995:46)], header: [Hunzib (van den Berg 1995:46)],
source_text: ([ождиг],[хо#super[н]хе],[мукъер]), source: ([ождиг],[хо#super[н]хе],[мукъер]),
transliteration: ([oʒdig],[χõχe],[muqʼer]), transliteration: ([oʒdig],[χõχe],[muqʼer]),
morphemes: ([ož-di-g],[xõxe],[m-uq'e-r]), morphemes: ([ož-di-g],[xõxe],[m-uq'e-r]),
additional_gloss_lines: ( additional-lines: (
([boy-#smallcaps[obl]-#smallcaps[ad]], [tree(#smallcaps[g4])], [#smallcaps[g4]-bend-#smallcaps[pret]]), ([boy-#smallcaps[obl]-#smallcaps[ad]], [tree(#smallcaps[g4])], [#smallcaps[g4]-bend-#smallcaps[pret]]),
([at boy], [tree], [bent]), ([at boy], [tree], [bent]),
), ),
@ -129,8 +129,8 @@ same arguments as `gloss`:
#codeblock( #codeblock(
"#gloss( "#gloss(
source_text: ([გვ-ფრცქვნ-ი],), source: ([გვ-ფრცქვნ-ი],),
source_text_style: none, source-style: none,
transliteration: ([gv-prtskvn-i],), transliteration: ([gv-prtskvn-i],),
morphemes: ([1#pl.#obj\-peel-#fmnt],), morphemes: ([1#pl.#obj\-peel-#fmnt],),
translation: \"You peeled us\", translation: \"You peeled us\",
@ -138,8 +138,8 @@ same arguments as `gloss`:
) )
#numbered-gloss( #numbered-gloss(
source_text: ([მ-ფრცქვნ-ი],), source: ([მ-ფრცქვნ-ი],),
source_text_style: none, source-style: none,
transliteration: ([m-prtskvn-i],), transliteration: ([m-prtskvn-i],),
morphemes: ([1#sg.#obj\-peel-#fmnt],), morphemes: ([1#sg.#obj\-peel-#fmnt],),
translation: \"You peeled me\", translation: \"You peeled me\",
@ -159,9 +159,9 @@ standard Typst counter functions to control gloss numbering:
"#gloss-count.update(20) "#gloss-count.update(20)
#numbered-gloss( #numbered-gloss(
header_text: [_Standard Basque: A Progressive Grammar_ by Rudolf de Rijk, quoting P. Charriton], header: [_Standard Basque: A Progressive Grammar_ by Rudolf de Rijk, quoting P. Charriton],
source_text: ([Bada beti guregan zorion handi baten nahia.],), source: ([Bada beti guregan zorion handi baten nahia.],),
source_text_style: none, source-style: none,
translation: [There always is in us a will for a great happiness.], translation: [There always is in us a will for a great happiness.],
)", addl-bindings: (gloss-count: gloss-count)) )", addl-bindings: (gloss-count: gloss-count))
@ -169,8 +169,8 @@ standard Typst counter functions to control gloss numbering:
== Styling lines of a gloss == Styling lines of a gloss
Each of the aforementioned text parameters has a corresponding style parameter, Each of the aforementioned text parameters has a corresponding style parameter,
formed by adding `_style` to its name: `header_text_style`, `source_text_style`, formed by adding `-style` to its name: `header-style`, `source-style`,
`transliteration_style`, `morphemes_style`, and `translation_style`. These parameters `transliteration-style`, `morphemes-style`, and `translation-style`. These parameters
allow you to specify formatting that should be applied to each entire line of allow you to specify formatting that should be applied to each entire line of
the gloss. This is particularly useful for the aligned gloss itself, since the gloss. This is particularly useful for the aligned gloss itself, since
otherwise one would have to modify each content item in the list individually. otherwise one would have to modify each content item in the list individually.
@ -181,12 +181,12 @@ way will override any contradictory line-level formatting.
#codeblock( #codeblock(
"#gloss( "#gloss(
header_text: [This text is about eating your head.], header: [This text is about eating your head.],
header_text_style: text.with(weight: \"bold\", fill: green), header-style: text.with(weight: \"bold\", fill: green),
source_text: (text(fill:black)[I'm], [eat-ing], [your], [head]), source: (text(fill:black)[I'm], [eat-ing], [your], [head]),
source_text_style: text.with(style: \"italic\", fill: red), source-style: text.with(style: \"italic\", fill: red),
morphemes: ([1#sg.#sbj\=to.be], text(fill:black)[eat-#prog], [2#sg.#poss], [head]), morphemes: ([1#sg.#sbj\=to.be], text(fill:black)[eat-#prog], [2#sg.#poss], [head]),
morphemes_style: text.with(fill: blue), morphemes-style: text.with(fill: blue),
translation: text(weight: \"bold\")[I'm eating your head!], translation: text(weight: \"bold\")[I'm eating your head!],
)", addl-bindings: (prog: prog, sbj: sbj, poss: poss, sg: sg)) )", addl-bindings: (prog: prog, sbj: sbj, poss: poss, sg: sg))
@ -202,8 +202,8 @@ with Typst field access notation or by importing them from `abbreviations`:
#gloss( #gloss(
header_text: [(from _Why Caucasian Languages?_, Bernard Comrie, in _Endangered Languages of the Caucasus and Beyond_)], header: [(from _Why Caucasian Languages?_, Bernard Comrie, in _Endangered Languages of the Caucasus and Beyond_)],
source_text: ([\[qálɐ-m], [∅-kw-á\]], [ɬ’ə́-r]), source: ([\[qálɐ-m], [∅-kw-á\]], [ɬ’ə́-r]),
morphemes: ([city-#obl], [3#sg\-go-#prf], [man-#abbreviations.abs]), morphemes: ([city-#obl], [3#sg\-go-#prf], [man-#abbreviations.abs]),
translation: "The man who went to the city." translation: "The man who went to the city."
) )
@ -213,8 +213,8 @@ with Typst field access notation or by importing them from `abbreviations`:
#import abbreviations: obl, sg, prf #import abbreviations: obl, sg, prf
#gloss( #gloss(
header_text: [(from _Why Caucasian Languages?_, by Bernard Comrie, in _Endangered Languages of the Caucasus and Beyond_)], header: [(from _Why Caucasian Languages?_, by Bernard Comrie, in _Endangered Languages of the Caucasus and Beyond_)],
source_text: ([\[qálɐ-m], [∅-kw-á\]], [ɬ’ə́-r]), source: ([\[qálɐ-m], [∅-kw-á\]], [ɬ’ə́-r]),
morphemes: ([city-#obl], [3#sg\-go-#prf], [man-#abbreviations.abs]), morphemes: ([city-#obl], [3#sg\-go-#prf], [man-#abbreviations.abs]),
translation: \"The man who went to the city.\" translation: \"The man who went to the city.\"
)") )")
@ -235,89 +235,89 @@ along with the Typst markup needed to generate them:
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Indonesian (Sneddon 1996:237)], header: [Indonesian (Sneddon 1996:237)],
source_text: ([Mereka], [di], [Jakarta], [sekarang.]), source: ([Mereka], [di], [Jakarta], [sekarang.]),
morphemes: ([they], [in], [Jakarta], [now]), morphemes: ([they], [in], [Jakarta], [now]),
translation: \"They are in Jakarta now\", translation: \"They are in Jakarta now\",
)") )")
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Lezgian (Haspelmath 1993:207)], header: [Lezgian (Haspelmath 1993:207)],
source_text: ([Gila], [abur-u-n], [ferma], [hamišaluǧ], [güǧüna], [amuq-da-č.]), source: ([Gila], [abur-u-n], [ferma], [hamišaluǧ], [güǧüna], [amuq-da-č.]),
morphemes: ([now], [they-#obl\-#gen], [farm], [forever], [behind], [stay-#fut\-#neg]), morphemes: ([now], [they-#obl\-#gen], [farm], [forever], [behind], [stay-#fut\-#neg]),
translation: \"Now their farm will not stay behind forever.\", translation: \"Now their farm will not stay behind forever.\",
)", addl-bindings: (fut: fut, neg: neg, obl: obl, gen:gen)) )", addl-bindings: (fut: fut, neg: neg, obl: obl, gen:gen))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [West Greenlandic (Fortescue 1984:127)], header: [West Greenlandic (Fortescue 1984:127)],
source_text: ([palasi=lu], [niuirtur=lu]), source: ([palasi=lu], [niuirtur=lu]),
morphemes: ([priest=and], [shopkeeper=and]), morphemes: ([priest=and], [shopkeeper=and]),
translation: \"both the priest and the shopkeeper\", translation: \"both the priest and the shopkeeper\",
)") )")
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Hakha Lai], header: [Hakha Lai],
source_text: ([a-nii -láay],), source: ([a-nii -láay],),
morphemes: ([3#sg\-laugh-#fut],), morphemes: ([3#sg\-laugh-#fut],),
translation: [s/he will laugh], translation: [s/he will laugh],
)", addl-bindings: (sg: sg, fut: fut)) )", addl-bindings: (sg: sg, fut: fut))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Russian], header: [Russian],
source_text: ([My], [s], [Marko], [poexa-l-i], [avtobus-om], [v], [Peredelkino]), source: ([My], [s], [Marko], [poexa-l-i], [avtobus-om], [v], [Peredelkino]),
morphemes: ([1#pl], [#com], [Marko], [go-#pst\-#pl], [bus-#ins], [#all], [Peredelkino]), morphemes: ([1#pl], [#com], [Marko], [go-#pst\-#pl], [bus-#ins], [#all], [Peredelkino]),
additional_gloss_lines: (([we], [with], [Marko], [go-#pst\-#pl], [bus-by], [to], [Peredelkino]),), additional-lines: (([we], [with], [Marko], [go-#pst\-#pl], [bus-by], [to], [Peredelkino]),),
translation: \"Marko and I went to Perdelkino by bus\", translation: \"Marko and I went to Perdelkino by bus\",
)", addl-bindings: (com: com, pl: pl, ins: ins, all: all, pst:pst)) )", addl-bindings: (com: com, pl: pl, ins: ins, all: all, pst:pst))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Turkish], header: [Turkish],
source_text: ([çık-mak],), source: ([çık-mak],),
morphemes: ([come.out-#inf],), morphemes: ([come.out-#inf],),
translation: \"to come out\", translation: \"to come out\",
)", addl-bindings: (inf: inf)) )", addl-bindings: (inf: inf))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Latin], header: [Latin],
source_text: ([insul-arum],), source: ([insul-arum],),
morphemes: ([island-#gen\-#pl],), morphemes: ([island-#gen\-#pl],),
translation: \"of the islands\", translation: \"of the islands\",
)", addl-bindings: (gen:gen, pl: pl)) )", addl-bindings: (gen:gen, pl: pl))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [French], header: [French],
source_text: ([aux], [chevaux]), source: ([aux], [chevaux]),
morphemes: ([to-#art\-#pl],[horse.#pl]), morphemes: ([to-#art\-#pl],[horse.#pl]),
translation: \"to the horses\", translation: \"to the horses\",
)",addl-bindings: (art:art, pl:pl)) )",addl-bindings: (art:art, pl:pl))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [German], header: [German],
source_text: ([unser-n], [Väter-n]), source: ([unser-n], [Väter-n]),
morphemes: ([our-#dat\-#pl],[father.#pl\-#dat.#pl]), morphemes: ([our-#dat\-#pl],[father.#pl\-#dat.#pl]),
translation: \"to our fathers\", translation: \"to our fathers\",
)", addl-bindings: (dat:dat, pl:pl)) )", addl-bindings: (dat:dat, pl:pl))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Hittite (Lehmann 1982:211)], header: [Hittite (Lehmann 1982:211)],
source_text: ([n=an], [apedani], [mehuni],[essandu.]), source: ([n=an], [apedani], [mehuni],[essandu.]),
morphemes: ([#smallcaps[conn]=him], [that.#dat.#sg], [time.#dat.#sg], [eat.they.shall]), morphemes: ([#smallcaps[conn]=him], [that.#dat.#sg], [time.#dat.#sg], [eat.they.shall]),
translation: \"They shall celebrate him on that date\", translation: \"They shall celebrate him on that date\",
)", addl-bindings: (pl:pl, sg:sg, dat:dat)) )", addl-bindings: (pl:pl, sg:sg, dat:dat))
#codeblock( #codeblock(
"#numbered-gloss( "#numbered-gloss(
header_text: [Jaminjung (Schultze-Berndt 2000:92)], header: [Jaminjung (Schultze-Berndt 2000:92)],
source_text: ([nanggayan], [guny-bi-yarluga?]), source: ([nanggayan], [guny-bi-yarluga?]),
morphemes: ([who], [2#du.#A.3#sg.#P\-#fut\-poke]), morphemes: ([who], [2#du.#A.3#sg.#P\-#fut\-poke]),
translation: \"Who do you two want to spear?\", translation: \"Who do you two want to spear?\",
)", addl-bindings: (du:du, sg:sg, fut:fut, A:A, P:P)) )", addl-bindings: (du:du, sg:sg, fut:fut, A:A, P:P))

View File

@ -2,7 +2,7 @@
#let gloss-count = counter("gloss_count") #let gloss-count = counter("gloss_count")
#let build_gloss(spacing_between_items, formatters, gloss_line_lists) = { #let build_gloss(item-spacing, formatters, gloss_line_lists) = {
assert(gloss_line_lists.len() > 0, message: "Gloss line lists cannot be empty") assert(gloss_line_lists.len() > 0, message: "Gloss line lists cannot be empty")
let len = gloss_line_lists.at(0).len() let len = gloss_line_lists.at(0).len()
@ -30,80 +30,80 @@
args.push(formatter_fn(item)) args.push(formatter_fn(item))
} }
make_item_box(..args) make_item_box(..args)
h(spacing_between_items) h(item-spacing)
} }
} }
#let gloss( #let gloss(
header_text: none, header: none,
header_text_style: none, header-style: none,
source_text: (), source: (),
source_text_style: emph, source-style: emph,
transliteration: none, transliteration: none,
transliteration_style: none, transliteration-style: none,
morphemes: none, morphemes: none,
morphemes_style: none, morphemes-style: none,
additional_gloss_lines: (), //List of list of content additional-lines: (), //List of list of content
translation: none, translation: none,
translation_style: none, translation-style: none,
spacing_between_items: 1em, item-spacing: 1em,
gloss_padding: 2.0em, //TODO document these gloss-padding: 2.0em, //TODO document these
left_padding: 0.5em, left_padding: 0.5em,
numbering: false, numbering: false,
breakable: false, breakable: false,
) = { ) = {
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) == "array", message: "source needs to be an array; perhaps you forgot to type `(` and `)`, or a trailing comma?")
if morphemes != none { 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(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") assert(source.len() == morphemes.len(), message: "source 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.len(), message: "source and transliteration have different lengths")
} }
let gloss_items = { let gloss_items = {
if header_text != none { if header != none {
if header_text_style != none { if header-style != none {
header_text_style(header_text) header-style(header)
} else { } else {
header_text header
} }
linebreak() linebreak()
} }
let formatters = (source_text_style,) let formatters = (source-style,)
let gloss_line_lists = (source_text,) let gloss_line_lists = (source,)
if transliteration != none { if transliteration != none {
formatters.push(transliteration_style) formatters.push(transliteration-style)
gloss_line_lists.push(transliteration) gloss_line_lists.push(transliteration)
} }
if morphemes != none { if morphemes != none {
formatters.push(morphemes_style) formatters.push(morphemes-style)
gloss_line_lists.push(morphemes) gloss_line_lists.push(morphemes)
} }
for additional in additional_gloss_lines { for additional in additional-lines {
formatters.push(none) //TODO fix this formatters.push(none) //TODO fix this
gloss_line_lists.push(additional) gloss_line_lists.push(additional)
} }
build_gloss(spacing_between_items, formatters, gloss_line_lists) build_gloss(item-spacing, formatters, gloss_line_lists)
if translation != none { if translation != none {
linebreak() linebreak()
if translation_style == none { if translation-style == none {
["#translation"] ["#translation"]
} else { } else {
translation_style(translation) translation-style(translation)
} }
} }
} }
@ -124,7 +124,7 @@
dir:ltr, //TODO this needs to be more flexible dir:ltr, //TODO this needs to be more flexible
left_padding, left_padding,
[#gloss_number], [#gloss_number],
gloss_padding - left_padding - measure([#gloss_number],styles).width, gloss-padding - left_padding - measure([#gloss_number],styles).width,
[#gloss_items] [#gloss_items]
) )
] ]