Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @digitallinguistics/scription2dlx with all npm packages installed. Try it out:

var scription2dlx = require("@digitallinguistics/scription2dlx")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@digitallinguistics/scription2dlx v0.11.0

A JavaScript library for converting linguistic texts in scription format to the DLx JSON format


GitHub version downloads GitHub issues tests status license DOI GitHub stars

A JavaScript library that converts linguistic texts in scription format to the Data Format for Digital Linguistics (DaFoDiL). This library is useful for language researchers who want to work with their data in text formats that are simple to type and read (scription), but want to convert their data for use in other Digital Linguistics tools.

Quick Links


Basic Usage

  1. Install the library using npm or yarn:
npm i @digitallinguistics/scription2dlx
yarn add @digitallinguistics/scription2dlx

Or download the latest release from the releases page.

  1. Import the library into your project:


import convert from '@digitallinguistics/scription2dlx';


<script src=scription2dlx.js type=module></script>
  1. The library exports a single function which accepts a string and returns a DaFoDiL Text Object.


title: How the world began
waxdungu qasi
one day a man


const data = await fetch(`data.txt`);
const text = scription2dlx(data);

console.log(text.utterances.transcription); // "waxdungu qasi"

You may also pass an options hash as the second option. See the Options section below.

const text = scription2dlx(data, { /* options */ });


  • If your project does not support ES modules and/or the latest JavaScript syntax, you may need to transpile this library using tools like Babel, and possibly bundle the library using a JavaScript bundler.

  • The scription2dlx library does not perform validation on the text data. You should use another validator like AJV to validate your data against the DLx DaFoDiL format.

  • In order to keep this library small and dependency-free, scription2dlx does not automatically parse the YAML header of a scription document. Instead, the header string is returned as a header property on the text object. If you would like scription2dlx to parse the header, pass a YAML parser to the parser option when calling the scription2dlx function:

    import yaml from 'yaml'; // use your preferred YAML parsing library
    const text = scription2dlx(data, { parser: yaml.parse });


alignmentError"warn"This option specifies whether the library should throw an error when it encounters an utterance which has a different number of words on each line, or a different number of morphemes in each word. The Leipzig glossing rules state that each line in an interlinear example must have the same number of words and morphemes on each line. By default, this option is set to "warn", which displays a warning if an alignment problem is encountered. To turn off warnings entirely, set this option to false; to throw an error, set this option to true.
codes{}This option allows you to use custom backslash codes in your interlinear glosses. It should be a hash containing the scription code as a key (without a leading backslash), and the custom code as the value; ex: "txn": "t" will allow you to write \t instead of \txn for transcription lines.
parserundefinedA YAML parser to use in parsing the header of a scription document. If none is present, the header will be provided as a string in the header property of the returned object.
utteranceMetadatatrueWhether to parse the utterance metadata line (the first line when it begins with #). If set to true, a metadata property will be added to each utterance that has it.
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free