12 Commits

Author SHA1 Message Date
Greg Shuflin
e655751043 Use label syntax in show, fix error 2023-07-06 01:48:25 -07:00
Greg Shuflin
30ede7255a Add leipzig-glossing- prefix 2023-07-06 01:41:07 -07:00
Greg Shuflin
af92697063 More label use 2023-07-06 01:34:25 -07:00
Greg Shuflin
af38aebc75 But this strategy using labels seems to work... 2023-07-06 01:16:04 -07:00
Greg Shuflin
32b0a2c936 Set rules for gloss
Doesn't currently work, see https://github.com/typst/typst/issues/147
2023-07-06 01:06:15 -07:00
Greg Shuflin
e61a58fac0 Add explanation of imports in README 2023-07-04 02:09:31 -07:00
Greg Shuflin
f2d524ac2d Add repository 2023-07-04 02:06:40 -07:00
Greg Shuflin
f1266322f4 Add typst.toml 2023-07-04 02:00:02 -07:00
Greg Shuflin
75f1232276 Add TODO 2023-07-04 01:54:37 -07:00
Greg Shuflin
6f70bdaa94 header and translation _style params 2023-07-04 01:52:43 -07:00
Greg Shuflin
f621f17f19 Minor code cleanup 2023-07-04 01:41:26 -07:00
Greg Shuflin
4abc5262c6 Edit readme 2023-07-04 01:22:18 -07:00
6 changed files with 123 additions and 20 deletions

View File

@@ -9,11 +9,22 @@ generate a pdf file with examples and documentation. This command is also
codified in the accompanying [justfile](https://github.com/casey/just) as `just
build-example`.
# License
The definitions intended for use by end users are the `#gloss` and
`#numbered_gloss` functions.
# Contributing
The canonical repository for this project is on the [Gitea
instance](https://code.everydayimshuflin.com/greg/typst-lepizig-glossing). The
repository is also [mirrored on
Github](https://github.com/neunenak/typst-leipzig-glossing/). Bug reports and
code contributions are welcome from all users.
## License
This library uses the MIT license; see `LICENSE.txt`.
# Contributors
## Contributors
Thanks to [Bethany E. Toma](https://github.com/betoma) for a number of
suggestions and improvements.

Binary file not shown.

View File

@@ -70,8 +70,8 @@ for common glossing abbreviations:
translation: text(weight: "semibold")[I'm eating your head!],
)
#codeblock(
[```typst
#codeblock[
```typst
#import "linguistic-abbreviations.typ": *
#gloss(
@@ -81,7 +81,8 @@ for common glossing abbreviations:
morphemes_style: text.with(fill: blue),
translation: text(weight: "semibold")[I'm eating your head!],
)
```])
```
]
The `#gloss` function has three pre-defined parameters for glossing levels:
@@ -106,8 +107,8 @@ parameters:
translation: ["Because of the boy, the tree bent."]
)
#codeblock(
[```typst
#codeblock[
```typst
#gloss(
header_text: [Hunzib (van den Berg 1995:46)],
source_text: ([ождиг],[хо#super[н]хе],[мукъер]),
@@ -119,7 +120,8 @@ parameters:
),
translation: ["Because of the boy, the tree bent."]
)
```])
```
]
To number gloss examples, use `#numbered_gloss` in place of `gloss`. All other parameters remain the same.
@@ -151,6 +153,45 @@ The gloss count is controlled by the Typst counter variable `gloss_count`. This
variable can be imported from the `leipzig-gloss` package and reset using the
standard Typst counter functions to control gloss numbering.
//TODO add examples here
== Styling lines of a gloss
Each of the aforementioned text parameters has a corresponding style parameter,
formed by adding `_style` to its name: `header_text_style`, `source_text_style`,
`transliteration_style`, `morphemes_style`, and `translation_style`. These parameters
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
otherwise one would have to modify each content item in the list individually.
In addition to these parameters, Typsts usual content formatting can be applied
to or within any given content block in the gloss. Formatting applied in this
way will override any contradictory line-level formatting.
#gloss(
header_text: [This text is about eating your head.],
header_text_style: text.with(weight: "bold", fill: green),
source_text: (text(fill:black)[I'm], [eat-ing], [your], [head]),
source_text_style: text.with(style: "italic", fill: red),
morphemes: ([1#sg.#sbj\=to.be], text(fill:black)[eat-#prog], [2#sg.#pos], [head]),
morphemes_style: text.with(fill: blue),
translation: text(weight: "bold")[I'm eating your head!],
)
#codeblock[
```typst
#gloss(
header_text: [This text is about eating your head.],
header_text_style: text.with(weight: "bold", fill: green),
source_text: (text(fill:black)[I'm], [eat-ing], [your], [head]),
source_text_style: text.with(style: "italic", fill: red),
morphemes: ([1#sg.#sbj\=to.be], text(fill:black)[eat-#prog], [2#sg.#pos], [head]),
morphemes_style: text.with(fill: blue),
translation: text(weight: "bold")[I'm eating your head!],
)
```
]
//TODO add `line_styles` param
== Further Example Glosses

View File

@@ -18,14 +18,15 @@
for item_index in range(0, len) {
let args = ()
for (line_idx, formatter) in formatters.enumerate() {
let formatter_fn = if formatter == none {
let label_string = "leipzig-glossing-" + formatter.label
let formatter_fn = if formatter.fn == none {
(x) => x
} else {
formatter
formatter.fn
}
let item = gloss_line_lists.at(line_idx).at(item_index)
args.push(formatter_fn(item))
args.push([#formatter_fn(item) #label(label_string)])
}
make_item_box(..args)
h(spacing_between_items)
@@ -35,6 +36,7 @@
#let gloss(
header_text: none,
header_text_style: none,
source_text: (),
source_text_style: emph,
transliteration: none,
@@ -43,6 +45,7 @@
morphemes_style: none,
additional_gloss_lines: (), //List of list of content
translation: none,
translation_style: none,
spacing_between_items: 1em,
gloss_padding: 2.0em, //TODO document these
left_padding: 0.5em,
@@ -62,23 +65,27 @@
let gloss_items = {
if header_text != none {
header_text
if header_text_style != none {
[#header_text_style(header_text) #label("leipzig-glossing-header_text")]
} else {
[#header_text #label("leipzig-glossing-header_text")]
}
linebreak()
}
let formatters = (source_text_style,)
let formatters = (("fn": source_text_style, "label": "source_text"),)
let gloss_line_lists = (source_text,)
if transliteration != none {
formatters.push(transliteration_style)
formatters.push(("fn": transliteration_style, "label": "transliteration"))
gloss_line_lists.push(transliteration)
}
formatters.push(morphemes_style)
formatters.push(("fn": morphemes_style, "label": "morpheme"))
gloss_line_lists.push(morphemes)
for additional in additional_gloss_lines {
formatters.push(none) //TODO fix this
formatters.push(("fn": none, "label": none)) //TODO fix this
gloss_line_lists.push(additional)
}
@@ -87,22 +94,25 @@
if translation != none {
linebreak()
["#translation"]
if translation_style == none {
["#translation"]
} else {
translation_style(translation)
}
}
}
if numbering {
gloss_count.step()
}
let gloss_number = if numbering {
[(#gloss_count.display())]
} else {
none
}
//[#gloss_number #pad(left: 1em)[#gloss_items]]
style(styles => {
block(breakable: breakable)[
#stack(

33
new-example.typ Normal file
View File

@@ -0,0 +1,33 @@
#import "leipzig-gloss.typ": gloss, numbered_gloss, gloss_count
#import "linguistic-abbreviations.typ": *
#show <leipzig-glossing-header_text>: set text(blue)
#show label("leipzig-glossing-source_text"): set text(weight: "bold")
= Saimiar
#let sc = smallcaps
From the song Tetrachromacy (_xoikesêcuxasø_) by King Gizzard.
#gloss(
header_text: [vath sêcubai dhiakŋo, somyxasan krexasir êsuŋo],
source_text: ([vath], [sêcu-bai], [dhika-ŋo], [so-my-xas-an], [kre-xas-ir], [êsu-ŋo]),
morphemes: ([three], [color-#sc[1sg]:#sc[pos]], [divide-#sc[cop]], [#sc[all]-un-see-#sc[nom]], [#sc[pot]-see-#sc[nom]], [desire-#sc[cop]]),
translation: [my three shades are divisible, lust to see the invisible],
)
#gloss(
header_text: [vath sêcubai dhiakŋo, somyxasan krexasir êsuŋo],
header_text_style: text.with(fill: green),
source_text: ([vath], [sêcu-bai], [dhika-ŋo], [so-my-xas-an], [kre-xas-ir], [êsu-ŋo]),
morphemes: ([three], [color-#sc[1sg]:#sc[pos]], [divide-#sc[cop]], [#sc[all]-un-see-#sc[nom]], [#sc[pot]-see-#sc[nom]], [desire-#sc[cop]]),
translation: [my three shades are divisible, lust to see the invisible],
)
#gloss(
header_text: [This text is about eating your head.],
source_text: (text(fill:black)[I'm], [eat-ing], [your], [head]),
morphemes: ([1#sg.#sbj\=to.be], text(fill:black)[eat-#prog], [2#sg.#pos], [head]),
translation: text(weight: "bold")[I'm eating your head!],
)

8
typst.toml Normal file
View File

@@ -0,0 +1,8 @@
[package]
name = "leipzig-glossing"
version = "0.1.0"
entrypoint = "leipzig-gloss.typ"
authors = ["Greg Shuflin", "Other open-source contributors"]
license = "MIT"
description = "Linguistic interlinear glosses according to the Leipzig Glossing rules"
repository = "https://code.everydayimshuflin.com/greg/typst-lepizig-glossing"