View on GitHub

scription2dlx

A JavaScript library that converts scription text files to DLx JSON format

scription2dlx

npm (scoped) npm GitHub issues Travis (.org) branch GitHub GitHub stars

A JavaScript library that converts linguistic texts in scription format to the Data Format for Digital Linguistics (DaFoDiL) in JSON. It runs in recent versions of browsers and Node.js. It 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.

Installation

Node

Install the library in your project from the command line: npm i @digitallinguistics/scription2dlx

Browser

Option 1: Include the scription2dlx library as a script in your HTML from the DLx CDN:

<script src=https://cdn.digitallinguistics.io/scripts/scription2dlx-0.1.0.js></script>

Option 2: Download the scription2dlx.js file from the releases page and include it in a script tag in your HTML:

<script src=scription2dlx.js></script>

Option 3: Install scription2dlx in your project using npm (see above), and then include the script in your HTML with a script tag. You may choose to use either the bundled distribution or the distribution that supports ES modules:

<script src=node_modules/@digitallinguistics/scription2dlx/scription2dlx.js></script>

Both options will make a global scription2dlx function available in the browser.

Usage

The library exports a single function, scription2dlx, which accepts a String and returns a DaFoDiL Text Object.

data.txt

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

script.js

const data = await fetch(`data.txt`);
const text = scription2dlx(data);
console.log(text.title); // "How the world began"

Using as a Dependency

If you would like to use scription2dlx as a dependency in your library, it is recommended that you use the files in the /src folder. The source code for the scription2dlx library is written using ES modules and the latest JavaScript syntax and features. You will need to bundle and/or transpile the code accordingly.