Interlinear glosses are a way of writing linguistic examples in a language other than the language of the main text (typically English). They first have a couple of lines of vertically aligned bits (however words are split in the original language) with, normally, some morphological information, and finally they might close with a free translation of the example. Most often they follow the Leipzig Glossing Rules.
R Markdown (Allaire et al. 2022) is an R package for literate programming, where you can weave together text and code. You can use R Markdown to write your papers, focusing on content rather than formatting, confident that the same source (pretty much) can turn into both a beautiful PDF file or a gorgeous web page with the minimum of effort. Yes, once you’re used to it, it’s not harder than writing in MS Word. I’ve written a bit about it in case you’re interested.
Mixing R Markdown and interlinear glosses has proved challenging.
This package offers you some wrapping functions that call the expex
\(\LaTeX\) package for PDF output and
leipzig.js for
HTML output and try to compute spaces to align the words in MS Word
output. You don’t really need to know any Latex or Javascript or HTML to
take advantage of these features.
The package also takes care of cross-references, giving you a handy
function gloss()
to sprinkle around your text every time
you want to reference one of your examples. Go ahead and check out the
articles and the
rendered versions of vignette("glossr_how")
.
I’m sure there is a lot of functionality in both expex
and leipzig.js that this package doesn’t cover… yet. Please, go
ahead and report any problems, suggestions and tasks for the wishlist in
the issues
section of the repository. Or fork it and contribute if you’d
like!
While this is a matter I’ve wondered about for a while, it was really kicked off by Giulia Mazzola’s worries. I’m converting her to the R Markdown crowd and I couldn’t let her resolve weaken because of these small matters. Thank you for your encouragement and appreciation!
I also want to thank Thomas Van Hoey for taking a look at the package, giving me suggestions and offering me examples.
Last but not least, I’d like to acknowledge the source of the examples in the small “dataset” provided by this package. These glosses were taken from Shindo (2015) and Pustet (2015). Any mistakes are mine.
Shortly before1 this package, another R package came out to render glosses in R Markdown with HTML output: lingglosses. Unlike glossr, it is tailored for HTML, where it creates a table to render the glosses2. It also allows grammaticality judgements, inline examples and sign language glosses, offers a list of abbreviations and generates a table from your glosses. In short, they have different focuses, so take a look and see what works for you :)