Compare commits

..

2 Commits

Author SHA1 Message Date
Greg Shuflin
7e08008ffa Some tweaks 2024-08-18 22:25:26 -07:00
Júda Ronén
7774532264 Add reference capability
This adds a new argument, `label`, and makes use of the referencing mechanism of Typst.
2024-08-17 19:21:54 +03:00
7 changed files with 26 additions and 40 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
*.pdf

View File

@ -1,10 +1,8 @@
# Changelog
## 0.3.0
* Added `label` and `label-supplement` arguments to `gloss` function
* Added borders around code + rendered example in documentation pdf
## 0.2.0
## 0.2.0 (upcoming)
* renamed `numbered_gloss` to `numbered-gloss`, `gloss_count` to `gloss-count`, in light of the
Typst style preference for kebab-case. Also renamed their arguments to use snake-case as well.
* Documented standard abbreviations

View File

@ -30,6 +30,3 @@ This library uses the MIT license; see `LICENSE.txt`.
Thanks to [Bethany E. Toma](https://github.com/betoma) for a number of
suggestions and improvements.
Thanks to [Maja Abramski-Kronenberg](https://github.com/rwmpelstilzchen) for
the labeling functionality.

Binary file not shown.

View File

@ -3,6 +3,8 @@
#show link: x => underline[*#x*]
#let codeblock-old(contents) = block(fill: luma(230), inset: 8pt, radius: 4pt, breakable: false, contents)
#let codeblock(contents, addl-bindings: (:), unevaled-first-line: none) = {
let full-contents = if unevaled-first-line != none {
unevaled-first-line + "\n" + contents
@ -10,10 +12,8 @@
contents
}
block(stroke: 0.5pt + black, inset: 4pt, width: 100%, breakable: false)[
#eval(contents, mode: "markup", scope: (gloss: gloss, numbered-gloss: numbered-gloss) + addl-bindings)
#block(fill: luma(230), inset: 8pt, radius: 4pt, breakable: false, width: 100%, raw(full-contents, lang: "typst"))
]
eval(contents, mode: "markup", scope: (gloss: gloss, numbered-gloss: numbered-gloss) + addl-bindings)
block(fill: luma(230), inset: 8pt, radius: 4pt, breakable: false, raw(full-contents, lang: "typst"))
}
// Abbreviations used in this document
@ -190,15 +190,11 @@ References to individual examples can be achieved using the `label` argument and
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\",
label-supplement: [Example]
label-suppliment: [Example]
)
As we have seen in @sorcerers, […].", addl-bindings: (neg: neg, sg: sg, pl: pl))
Labeling uses the Typst #link("https://typst.app/docs/reference/model/figure/")[figure] document element. The `label-supplement`
parameter fills in the `suppliment` parameter of a `figure`, which is `[example]` by default.
== Styling lines of a gloss
Each of the aforementioned text parameters has a corresponding style parameter,

View File

@ -2,16 +2,16 @@
#let gloss-count = counter("gloss_count")
#let build-gloss(item-spacing, formatters, gloss-line-lists) = {
assert(gloss-line-lists.len() > 0, message: "Gloss line lists cannot be empty")
#let build_gloss(item-spacing, formatters, gloss_line_lists) = {
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()
for line in gloss-line-lists {
for line in gloss_line_lists {
assert(line.len() == len)
}
assert(formatters.len() == gloss-line-lists.len(), message: "The number of formatters and the number of gloss line lists should be equal")
assert(formatters.len() == gloss_line_lists.len(), message: "The number of formatters and the number of gloss line lists should be equal")
let make_item_box(..args) = {
box(stack(dir: ttb, spacing: 0.5em, ..args))
@ -26,7 +26,7 @@
formatter
}
let item = gloss-line-lists.at(line_idx).at(item_index)
let item = gloss_line_lists.at(line_idx).at(item_index)
args.push(formatter_fn(item))
}
make_item_box(..args)
@ -52,11 +52,11 @@
translation: none,
translation-style: none,
label: none,
label-supplement: [example],
label-suppliment: [example],
item-spacing: 1em,
gloss-padding: 2.0em, //TODO document these
left-padding: 0.5em,
left_padding: 0.5em,
numbering: false,
breakable: false,
) = {
@ -84,25 +84,25 @@
}
let formatters = (source-style,)
let gloss-line-lists = (source,)
let gloss_line_lists = (source,)
if transliteration != none {
formatters.push(transliteration-style)
gloss-line-lists.push(transliteration)
gloss_line_lists.push(transliteration)
}
if morphemes != none {
formatters.push(morphemes-style)
gloss-line-lists.push(morphemes)
gloss_line_lists.push(morphemes)
}
for additional in additional-lines {
formatters.push(none) //TODO fix this
gloss-line-lists.push(additional)
gloss_line_lists.push(additional)
}
build-gloss(item-spacing, formatters, gloss-line-lists)
build_gloss(item-spacing, formatters, gloss_line_lists)
if translation != none {
linebreak()
@ -120,7 +120,7 @@
}
let gloss_number = if numbering {
[(#context gloss-count.display())]
[(#gloss-count.display())]
} else {
none
}
@ -129,13 +129,13 @@
block(breakable: breakable)[
#figure(
kind: "ling-example",
supplement: label-supplement,
supplement: label-suppliment,
numbering: it => [#gloss-count.display()],
stack(
dir: ltr, //TODO this needs to be more flexible
left-padding,
left_padding,
[#gloss_number],
gloss-padding - left-padding - measure([#gloss_number],styles).width,
gloss-padding - left_padding - measure([#gloss_number],styles).width,
align(left)[#gloss_items],
),
) #if label != none {cmdlabel(label)}

View File

@ -1,12 +1,8 @@
[package]
name = "leipzig-glossing"
version = "0.3.0"
version = "0.2.0"
entrypoint = "leipzig-gloss.typ"
authors = ["Greg Shuflin <greg@everydayimshuflin.com>", "Other open-source contributors"]
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"
disciplines = ["linguistics"]
categories = ["paper"]
keywords = ["linguistics", "leipzig", "gloss", "glossing"]
compiler = "0.11.0"