-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
26 lines (20 loc) · 715 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
const transforms = require('./transforms.js');
module.exports = function ConverterODT(Asciidoctor, {styles}) {
class ODTConverter {
constructor(backend, opts) {
this.basebackend = 'xml';
this.outfilesuffix = '.odt';
this.filetype = 'xml';
this.htmlsyntax = 'xml';
}
$convert(node, transform = null, opts = {}) {
const operation = transforms[transform || node.node_name];
if (!operation) {
throw new Error(`${operation} operation does not exist. (${transform}, ${node.node_name}, ${node.context})`);
}
return operation({ node, styles });
}
}
Asciidoctor.ConverterFactory.register(new ODTConverter('odt'), ['odt']);
};