tvim-parser
v0.0.2
Published
> This package implements parsing of the tvim articles which have certain TeX structure.
Downloads
2
Readme
tvim-parser
This package implements parsing of the tvim articles which have certain TeX structure.
Install
$ npm install tvim-parser
Usage
The formats
parameter is expected to be an array of objects as follows:
[
{
name: "tvim_ref", // Name of this type of article
tag: "^\\\\tvimRef\n", // JS-compatible regex of the corresponding TeX tag
fields: [ // array of fields to extract, in order they appear in the TeX file
"main_author",
"authors",
// ...
]
},
// ...
]
The contents
parameter is expected to be a string with contents of the TeX file to parse. TeX file must have the following structure to be parsed correctly:
\tvimRef
{Author 1}
{Author 1, Author 2, \textit{Author 3}}
i. e. there should be a tag, followed by a sequence of parameters, enclosed in curly braces. Example usage:
const path = require('path');
const fs = require('fs');
const tvimParser = require('tvim-parser');
let formats = JSON.parse(fs.readFileSync(path.resolve('./test/formats.example.json'), 'utf8'));
let contents = fs.readFileSync(path.resolve('./test/example.tex'), 'utf8');
let result = tvimParser(formats, contents);
The result
variable is expected to have the following value:
result = {
tvim_ref: [
{
main_author: "Author 1",
authors: "Author 1, Author 2, \\textit{Author 3}",
// ..
},
// ...
],
// ...
}
License
MIT