Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelidlessness committed Dec 28, 2022
1 parent d4616e8 commit e8c5f90
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e8c5f90

Please sign in to comment.