Install the library in your project from the command line:
npm i @digitallinguistics/scription2dlx
Option 1: Include the
scription2dlx library as a script in your HTML from the DLx CDN:
Option 2: Download the
scription2dlx.js file from the releases page and include it in a script tag in your HTML:
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:
The library exports a single function,
scription2dlx, which accepts a String and returns a DaFoDiL Text Object.
--- title: How the world began --- waxdungu qasi one day a man
const data = await ;const text = ;console; // "waxdungu qasi"
You may also pass an options hash as the second option. The available options are shown below.
const text = ;
scription2dlxlibrary 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,
scription2dlxdoes not automatically parse the YAML header of a scription document. Instead, the header string is returned as a
headerproperty on the text object. If you would like
scription2dlxto parse the header, pass a YAML parser to the
parseroption when calling the
scription2dlxfunction:; // use your preferred YAML parsing libraryconst text = ;
||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:
|parser||undefined||A YAML parser to use to parse the header of a scription document. If none is present, the header will be provided as a string in the
Using as a Dependency
If you would like to include
scription2dlx as a dependency in your own library, you can use the files in the
/src directory to transpile / bundle
scription2dlx with your own code. The source code for