Home

Awesome

Leipzig.js

Interlinear glossing for the browser

Leipzig.js is a small JavaScript utility that makes it easy to add interlinear glosses to webpages.

npm badge bower badge

Table of Contents


Overview

An interlinear gloss is a way of presenting linguistic data that helps makes it clear what the different words and morphemes of a phrase mean. They consist of multiple lines of data, aligned horizontally at the word boundaries of the original language.

Many interlinear glosses consist of three lines:

  1. The first line is used for data in the original language;
  2. A morpheme-by-morpheme analysis of the original language;
  3. A free or colloquial translation, not aligned at word boundaries.

Additional lines may be used to show phonemic information, or other analyses that might be relevant to the phrase being glossed.

Interlinear glosses help linguists present language data to audiences that might not be familiar with the language being analyzed, and are an integral part of documenting and discussing languages.

Enter Leipzig.js

Leipzig.js aims to be a simple, lightweight solution for interlinear glossing on the web. By relying on existing HTML tags, it degrades gracefully when either JavaScript or CSS is not present.

While basic usage of Leipzig.js is dead simple (see the Usage section below), more customizable glossing can be achieved by using the library's flexible API.

Glosses formatted with Leipzig.js are responsive, and contain numerous CSS classes that can be used to style individual lines in the gloss.

Leipzig.js tries to strike the right balance between ease of creation and beauty of output. It should be easy enough to use for people new to web authorship, while remaining powerful and customizable enough for people that want more control over their interlinear glosses.

Compatability & Dependencies

Leipzig.js has no front-end dependencies, and should work on most modern browsers, including IE9+.

Further Reading

For more information about interlinear glossing, visit the homepage for the Leipzig Glossing Rules (from which Leipzig.js gets its name). The Leipzig Glossing rules homepage also contains references to other important works on interlinear glossing.

Back to Top ↑


Usage

1. Download It (Optional)

You can install Leipzig.js using npm or Bower, or by downloading the latest version from the github repository:

$ npm install --save leipzig
$ bower install --save leipzig
$ git clone https://github.com/bdchauvette/leipzig.js.git

Alternatively, you can skip installing Leipzig.js on your own server, and can use the jsDelivr CDN as described in the next step.

2. Include It

Include the main leipzig.js file somewhere on your page, ideally at the bottom of the <body>:

<script src="path/to/leipzig/dist/leipzig.min.js"></script>

Leipzig.js comes with some basic styling, which you can include by adding the Leipzig.js stylesheet in the <head> of your page:

<link rel="stylesheet" href="path/to/leipzig/dist/leipzig.css">

jsDelivr

You can also include the latest version of Leipzig.js automatically by linking to the project files on the jsDelivr CDN:

<!-- CSS -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/leipzig@latest/dist/leipzig.min.css">

<!-- JavaScript -->
<script src="//cdn.jsdelivr.net/npm/leipzig@latest/dist/leipzig.min.js"></script>

For more information about jsDelivr, you can visit the jsDelivr homepage or read the following blog posts:

3. Mark Up Your Examples

To use the Leipzig.js default configuration, just add a data-gloss attribute to the examples you want to be glossed:

<div data-gloss>
  <p>Gila abur-u-n ferma hamišaluǧ güǧüna amuq’-da-č.</p>
  <p>now they-OBL-GEN farm forever behind stay-FUT-NEG</p>
  <p>‘Now their farm will not stay behind forever.’</p>
</div>

Leipzig.js will find all of the blocks that have the data-gloss attribute and turn them into nicely formatted interlinear glosses.

4. Gloss ’Em

Finally, you just need to tell Leipzig.js to go to work by adding the following <script> somewhere after the one you added in Step 2:

<script>
  document.addEventListener('DOMContentLoaded', function() {
    Leipzig().gloss();
  });
</script>

If you're using jQuery, you can use the following script instead:

<script>
  $(function() { Leipzig().gloss(); });
</script>

Minimal Example

<html>
  <head>
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/leipzig@latest/dist/leipzig.min.css">
  </head>
  <body>
    <div data-gloss>
      <p>Ein Beispiel</p>
      <p>DET.NOM.N.SG example</p>
      <p>‘An example’</p>
    </div>
    <script src="//cdn.jsdelivr.net/npm/leipzig@latest/dist/leipzig.min.js"></script>
    <script>
      document.addEventListener('DOMContentLoaded', function() {
        Leipzig().gloss();
      });
    </script>
  </body>
</html>

Back to Top ↑


Documentation

Please see the Documentation page on the wiki.

Back to Top ↑


Examples

Please see the Examples page on the Leipzig.js homepage.

Back to Top ↑


Contributing

$ git clone https://github.com/bdchauvette/leipzig.js.git
$ cd leipzig.js
$ npm install

Building

The main source files are in src/.

Leipzig.js uses gulp to build the files for distribution found in dist/. The following tasks are available:

TaskDoes
jsTranspiles and minifies the main JS file
cssCompiles & minifies the main Sass stylesheet
buildRuns the js and css tasks
watchWatches for changes to files in src/, then runs the appropriate task
combRuns csscomb on any Sass files in src/

You can run these tasks by installing gulp (npm i -g gulp) then running:

$ gulp $TASKNAME # e.g. gulp build or gulp watch

Testing

Leipzig.js uses a tape-based testing system.

To run the complete test suite, you'll first need to have browserify and tape-run installed globally:

$ npm i -g browserify tape-run

You can then run the complete test suite using:

$ npm test

Back to Top ↑


Other Solutions

Plain CSS

Both Kevin McGowan and James Tauber describe methods for styling interlinear glosses using pure CSS. McGowan also hints at a JavaScript solution that seems similar to what Leipzig.js is doing, but no code is provided.

interlinear

interlinear, like Leipzig.js, is a JavaScript + CSS utility that automatically formats selected HTML elements. interlinear has a different feature set than Leipzig.js, and uses a different syntax for marking up glosses. If Leipzig.js is not to your liking, I recommend taking a look at interlinear.

glosser

glosser is a small utility for producing interlinear glosses in plaintext or formatted for reddit.

Back to Top ↑


Further Reading

For more information about interlinear glossing, visit the homepage for the Leipzig Glossing Rules (from which Leipzig.js gets its name). The Leipzig Glossing rules homepage also contains references to other important works on interlinear glossing.

Back to Top ↑

License

Leipzig.js is licensed under the ISC License.

For details, please see the LICENSE file.

Back to Top ↑