From e8c5f905ddc4894b4d7dc4f9e1d3f058de301356 Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Wed, 28 Dec 2022 10:03:43 -0800 Subject: [PATCH] Update README --- README.md | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 247d725..7d800d7 100644 --- a/README.md +++ b/README.md @@ -20,30 +20,32 @@ npm install enketo-transformer --save ### Use as module -```js -const transformer = require('enketo-transformer'); +```ts +import { transform } from 'enketo-transformer'; + const xform = fs.readFileSync('path/to/xform.xml'); +const result = await transform({ + // required string of XForm + xform: xform, + + // optional string, to add theme if no theme is defined in the XForm + theme: 'sometheme', + + // optional map, to replace jr://..../myfile.png URLs + media: { + 'myfile.png': '/path/to/somefile.png', + 'myfile.mp3': '/another/path/to/2.mp3', + }, + + // optional ability to disable markdown rendering (default is true) + markdown: false, + + // optional preprocess function that transforms the XForm (as libXMLJs object) to + // e.g. correct incompatible XForm syntax before Enketo's transformation takes place + preprocess: (doc) => doc, +}); -transformer - .transform({ - // required string of XForm - xform: xform, - // optional string, to add theme if no theme is defined in the XForm - theme: 'sometheme', - // optional map, to replace jr://..../myfile.png URLs - media: { - 'myfile.png': '/path/to/somefile.png', - 'myfile.mp3': '/another/path/to/2.mp3', - }, - // optional ability to disable markdown rendering (default is true) - markdown: false, - // optional preprocess function that transforms the XForm (as libXMLJs object) to - // e.g. correct incompatible XForm syntax before Enketo's transformation takes place - preprocess: (doc) => doc, - }) - .then(function (result) { - // do something with result - }); +// ... do something with result ``` ### Install as app (web API)