19 Commits

Author SHA1 Message Date
Greg Shuflin
6592ebd444 Use snake-case 2023-07-11 01:40:00 -07:00
Greg Shuflin
2b5cad038d Use-order and alphabetical used symbols 2023-07-11 01:33:29 -07:00
Greg Shuflin
6fee9d6e4c More misc work 2023-07-11 01:17:41 -07:00
Greg Shuflin
3c87ec58c8 Hide helper function in closure 2023-07-11 00:42:45 -07:00
Greg Shuflin
4519b8da22 WIP tryign out ways to define custom abbreviations 2023-07-10 03:20:42 -07:00
Greg Shuflin
ae47d30fef Handle N- (non-) ? 2023-07-10 03:00:53 -07:00
Greg Shuflin
ff20fc0c76 More code simplifications 2023-07-10 02:51:34 -07:00
Greg Shuflin
fe6de041a5 Ensure ordering of used abbrevs is correct 2023-07-10 02:49:04 -07:00
Greg Shuflin
26e0bbdab6 Flesh out full linguistics abbreviation chart 2023-07-10 02:44:03 -07:00
Greg Shuflin
ffec36460d Simplify how tracking abbreviations works 2023-07-10 02:23:15 -07:00
Greg Shuflin
c45e645b1a Concision 2023-07-10 02:19:57 -07:00
Greg Shuflin
e837580f68 Playing around with how a used abbreviations table might work 2023-07-05 21:12:52 -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
8 changed files with 356 additions and 139 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.

View File

@@ -0,0 +1,58 @@
#import "linguistic-abbreviations.typ": *
#let custom-abbreviations = (
"FMNT": "Present/Future stem formant",
)
#let fmnt = emit-abbreviation("FMNT")
// An example function that uses `with-used-abbreviations`
#let print_usage_chart = with-used-abbreviations.with(debug: false)(final-used-abbreviations => {
show terms: t => {
for t in t.children [
#t.term #h(2cm) #t.description\
]
}
let print-abbrevs(abbrv_list) = {
for abbrv in abbrv_list {
let explanation = if abbrv in standard-abbreviations {
standard-abbreviations.at(abbrv)
} else {
custom-abbreviations.at(abbrv)
}
terms((smallcaps(lower(abbrv)), explanation))
}
}
heading(level: 3)[Abbreviations in order of use]
print-abbrevs(final-used-abbreviations.keys())
heading(level: 3)[Abbreviations in alphabetical order]
let sorted-abbreviations = final-used-abbreviations.keys().sorted()
print-abbrevs(sorted-abbreviations)
})
= Some linguistics paper
== Abbreviations used in this document
#print_usage_chart
== The main body of the paper
The #p1#sg pronoun in Spanish is _yo_. The #p2#sg pronoun in Spanish is _tu_.
The six cases of Latin are:
- Nominative (#nom)
- Genitive (#gen)
- Dative (#dat)
- Accusative (#acc)
- Ablative (#abl)
- Vocative (#voc)
The Present/Future stem formant (#fmnt) in Georgian disappears in perfective screeves.

View File

@@ -4,3 +4,7 @@ default:
build-example:
typst compile leipzig-gloss-examples.typ
build-abbreviations-example:
typst compile abbreviations-used-example.typ

Binary file not shown.

View File

@@ -65,13 +65,13 @@ for common glossing abbreviations:
#gloss(
source_text: ([I'm], [eat-ing], [your], [head]),
source_text_style: (item) => text(fill: red)[#item],
morphemes: ([1#sg.#sbj\=to.be], [eat-#prog], [2#sg.#pos], [head]),
morphemes: ([1#sg.#sbj\=to.be], [eat-#prog], [2#sg.#poss], [head]),
morphemes_style: text.with(fill: blue),
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.#poss], [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.#poss], [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

@@ -35,6 +35,7 @@
#let gloss(
header_text: none,
header_text_style: none,
source_text: (),
source_text_style: emph,
transliteration: none,
@@ -43,6 +44,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,7 +64,11 @@
let gloss_items = {
if header_text != none {
header_text
if header_text_style != none {
header_text_style(header_text)
} else {
header_text
}
linebreak()
}
@@ -87,22 +93,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(

View File

@@ -1,128 +1,214 @@
#let fmnt = smallcaps([fmnt])
// See https://www.eva.mpg.de/lingua/resources/glossing-rules.php
#let standard-abbreviations = (
"1": "first person",
"2": "second person",
"3": "third person",
"A": "agent-like argument of canonical transitive verb",
"ABL": "ablative",
"ABS": "absolutive",
"ACC": "accusative",
"ADJ": "adjective",
"ADV": "adverb(ial)",
"AGR": "agreement",
"ALL": "allative",
"ANTIP": "antipassive",
"APPL": "applicative",
"ART": "article",
"AUX": "auxiliary",
"BEN": "benefactive",
"CAUS": "causative",
"CLF": "classifier",
"COM": "comitative",
"COMP": "complementizer",
"COMPL": "completive",
"COND": "conditional",
"COP": "copula",
"CVB": "converb",
"DAT": "dative",
"DECL": "declarative",
"DEF": "definite",
"DEM": "demonstrative",
"DET": "determiner",
"DIST": "distal",
"DISTR": "distributive",
"DU": "dual",
"DUR": "durative",
"ERG": "ergative",
"EXCL": "exclusive",
"F": "feminine",
"FOC": "focus",
"FUT": "future",
"GEN": "genitive",
"IMP": "imperative",
"INCL": "inclusive",
"IND": "indicative",
"INDF": "indefinite",
"INF": "infinitive",
"INS": "instrumental",
"INTR": "intransitive",
"IPFV": "imperfective",
"IRR": "irrealis",
"LOC": "locative",
"M": "masculine",
"N": "neuter",
"N-": [non- (e.g. #smallcaps[nsg] nonsingular, #smallcaps[npst] nonpast)],
"NEG": "negation, negative",
"NMLZ": "nominalizer/nominalization",
"NOM": "nominative",
"OBJ": "object",
"OBL": "oblique",
"P": "patient-like argument of canonical transitive verb",
"PASS": "passive",
"PFV": "perfective",
"PL": "plural",
"POSS": "possessive",
"PRED": "predicative",
"PRF": "perfect",
"PRS": "present",
"PROG": "progressive",
"PROH": "prohibitive",
"PROX": "proximal/proximate",
"PST": "past",
"PTCP": "participle",
"PURP": "purposive",
"Q": "question particle/marker",
"QUOT": "quotative",
"RECP": "reciprocal",
"REFL": "reflexive",
"REL": "relative",
"RES": "resultative",
"S": "single argument of canonical intransitive verb",
"SBJ": "subject",
"SBJV": "subjunctive",
"SG": "singular",
"TOP": "topic",
"TR": "transitive",
"VOC": "vocative",
)
// A dictionary used as a set to mark which abbreviations have been used by a call to
// `emit-abbreviation`. Each key in the dictionary is the string symbol of that abbreviation,
// and the value is always `true`.
#let used-abbreviations = state("leipzig-gloss-used-abbreviations", (:))
// Accepts a callback that accepts the state of the `used-abbreviations`
// dictionary at the end of the document. Also an additional debug parameter
#let with-used-abbreviations(callback, debug: false) = {
locate(loc => {
let final_used-abbreviations = used-abbreviations.final(loc)
if debug {
for (key, value) in final_used-abbreviations {
[#key was used: #value]
linebreak()
}
linebreak()
}
callback(final_used-abbreviations)
})
}
// Public function. Given a symbol that is a string, emits
// the lowercase version of that string in smallcaps format, and adds
// its use to the `used-abbreviations` table
#let emit-abbreviation(symbol) = {
let mark_used(symbol) = {
used-abbreviations.update(cur => {
cur.insert(symbol, true)
cur
})
}
mark_used(symbol)
smallcaps(lower(symbol))
}
/*
Appendix: List of Standard Abbreviations
#let p1 = emit-abbreviation("1")
#let p2 = emit-abbreviation("2")
#let p3 = emit-abbreviation("3")
#let A = emit-abbreviation("A")
#let abl = emit-abbreviation("ABL")
#let abs = emit-abbreviation("ABS")
#let acc = emit-abbreviation("ACC")
#let adj = emit-abbreviation("ADJ")
#let adv = emit-abbreviation("ADV")
#let agr = emit-abbreviation("AGR")
#let all = emit-abbreviation("ALL")
#let antip = emit-abbreviation("ANTIP")
#let appl = emit-abbreviation("APPL")
#let art = emit-abbreviation("ART")
#let aux = emit-abbreviation("AUX")
#let ben = emit-abbreviation("BEN")
#let caus = emit-abbreviation("CAUS")
#let clf = emit-abbreviation("CLF")
#let com = emit-abbreviation("COM")
#let comp = emit-abbreviation("COMP")
#let compl = emit-abbreviation("COMPL")
#let cond = emit-abbreviation("COND")
#let cop = emit-abbreviation("COP")
#let cvb = emit-abbreviation("CVB")
#let dat = emit-abbreviation("DAT")
#let decl = emit-abbreviation("DECL")
#let def = emit-abbreviation("DEF")
#let dem = emit-abbreviation("DEM")
#let det = emit-abbreviation("DET")
#let dist = emit-abbreviation("DIST")
#let distr = emit-abbreviation("DISTR")
#let du = emit-abbreviation("DU")
#let dur = emit-abbreviation("DUR")
#let erg = emit-abbreviation("ERG")
#let excl = emit-abbreviation("EXCL")
#let F = emit-abbreviation("F")
#let foc = emit-abbreviation("FOC")
#let fut = emit-abbreviation("FUT")
#let gen = emit-abbreviation("GEN")
#let imp = emit-abbreviation("IMP")
#let incl = emit-abbreviation("INCL")
#let ind = emit-abbreviation("IND")
#let indf = emit-abbreviation("INDF")
#let inf = emit-abbreviation("INF")
#let ins = emit-abbreviation("INS")
#let intr = emit-abbreviation("INTR")
#let ipfv = emit-abbreviation("IPFV")
#let irr = emit-abbreviation("IRR")
#let loc = emit-abbreviation("LOC")
#let M = emit-abbreviation("M")
#let N = emit-abbreviation("N")
#let non = emit-abbreviation("N-")
#let neg = emit-abbreviation("NEG")
#let nmlz = emit-abbreviation("NMLZ")
#let nom = emit-abbreviation("NOM")
#let obj = emit-abbreviation("OBJ")
#let obl = emit-abbreviation("OBL")
#let P = emit-abbreviation("P")
#let pass = emit-abbreviation("PASS")
#let pfv = emit-abbreviation("PFV")
#let pl = emit-abbreviation("PL")
#let poss = emit-abbreviation("POSS")
#let pred = emit-abbreviation("PRED")
#let prf = emit-abbreviation("PRF")
#let prs = emit-abbreviation("PRS")
#let prog = emit-abbreviation("PROG")
#let proh = emit-abbreviation("PROH")
#let prox = emit-abbreviation("PROX")
#let pst = emit-abbreviation("PST")
#let ptcp = emit-abbreviation("PTCP")
#let purp = emit-abbreviation("PURP")
#let Q = emit-abbreviation("Q")
#let quot = emit-abbreviation("QUOT")
#let recp = emit-abbreviation("RECP")
#let refl = emit-abbreviation("REFL")
#let rel = emit-abbreviation("REL")
#let res = emit-abbreviation("RES")
#let S = emit-abbreviation("S")
#let sbj = emit-abbreviation("SBJ")
#let sbjv = emit-abbreviation("SBJV")
#let sg = emit-abbreviation("SG")
#let top = emit-abbreviation("TOP")
#let tr = emit-abbreviation("TR")
#let voc = emit-abbreviation("VOC")
1 first person
2 second person
3 third person
A agent-like argument of canonical transitive verb
ABL ablative
ABS absolutive
ACC accusative
ADJ adjective
ADV adverb(ial)
AGR agreement
ALL allative
ANTIP antipassive
APPL applicative
ART article
AUX auxiliary
BEN benefactive
*/
#let A = smallcaps([a])
#let all = smallcaps([all])
#let art = smallcaps([art])
/*
CAUS causative
CLF classifier
COM comitative
COMP complementizer
COMPL completive
COND conditional
COP copula
CVB converb
DAT dative
DECL declarative
DEF definite
DEM demonstrative
DET determiner
DIST distal
*/
#let com = smallcaps([com])
#let dat = smallcaps([dat])
/*
DISTR distributive
DU dual
DUR durative
ERG ergative
EXCL exclusive
F feminine
FOC focus
FUT future
GEN genitive
IMP imperative
INCL inclusive
IND indicative
INDF indefinite
INF infinitive
INS instrumental
INTR intransitive
IPFV imperfective
*/
#let du = smallcaps([du])
#let fut = smallcaps([fut])
#let gen = smallcaps([gen])
#let inf = smallcaps([inf])
#let ins = smallcaps([ins])
/*
IRR irrealis
LOC locative
M masculine
N neuter
N- non- (e.g. NSG nonsingular, NPST nonpast)
NEG negation, negative
NMLZ nominalizer/nominalization
NOM nominative
OBJ object
OBL oblique
P patient-like argument of canonical transitive verb
PASS passive
PFV perfective
PL plural
*/
#let obl = smallcaps([obl])
#let neg = smallcaps([neg])
#let obj = smallcaps([obj])
#let pl = smallcaps([pl])
/*
POSS possessive
PRED predicative
PRF perfect
PRS present
PROG progressive
PROH prohibitive
PROX proximal/proximate
PST past
PTCP participle
PURP purposive
Q question particle/marker
QUOT quotative
RECP reciprocal
REFL reflexive
*/
#let P = smallcaps([p])
#let pos = smallcaps([pos])
#let prog = smallcaps([prog])
#let pst = smallcaps([pst])
/*
REL relative
RES resultative
S single argument of canonical intransitive verb
SBJ subject
SBJV subjunctive
SG singular
TOP topic
TR transitive
VOC vocative
*/
#let sg = smallcaps([sg])
#let sbj = smallcaps([sbj])

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"