-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathindex.ts
38 lines (30 loc) · 1.18 KB
/
index.ts
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
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const eejs = require('ep_etherpad-lite/node/eejs');
const settings = require('ep_etherpad-lite/node/utils/Settings');
import {promises} from 'fs';
const fsp = promises
exports.eejsBlock_exportColumn = (hookName, context) => {
context.content += eejs.require('./templates/exportcolumn.html', {}, module);
};
exports.eejsBlock_styles = (hookName, context) => {
context.content += eejs.require('./templates/styles.html', {}, module);
};
exports.eejsBlock_mySettings = (hookName, context) => {
let checkedState = 'unchecked';
if (!settings.ep_markdown_default) {
checkedState = 'unchecked';
} else if (settings.ep_markdown_default === true) {
checkedState = 'checked';
}
context.content +=
eejs.require('./templates/markdown_entry.ejs', {checked: checkedState}, module);
};
exports.import = async (hookName, {destFile, fileEnding, srcFile}) => {
if (fileEnding !== '.md') return;
const markdown = await fsp.readFile(srcFile, 'utf8');
const showdown = require('showdown');
const converter = new showdown.Converter({completeHTMLDocument: true});
const html = converter.makeHtml(markdown);
await fsp.writeFile(destFile, html, 'utf8');
return destFile;
};