-
Notifications
You must be signed in to change notification settings - Fork 1
/
CheckInsert.js
34 lines (26 loc) · 1000 Bytes
/
CheckInsert.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
27
28
29
30
31
32
33
34
//const toc = require('markdown-toc');
const insert = require('./lib/insert.js');
const elfUtils = require('elven-code').elfUtils;
const fileName = './CloudNotes.md';
const elf = require('markdown-elf');
const toc = require('markdown-toc');
async function getFile(str, options) {
var regex = options.regex || /(?:<!-- toc(?:\s*stop)? -->)/g;
var open = typeof options.open === 'string' ? options.open : '<!-- toc -->\n\n';
var close = typeof options.close === 'string' ? options.close : '<!-- tocstop -->';
let markdown = await elfUtils.readFileAsync(fileName);
console.log(open);
console.log(close);
console.log(insert(markdown));
}
async function getMarkdown(str, options) {
let markdown = await elfUtils.readFileAsync(fileName);
markdown = toc.insert(markdown)
console.log(insert(markdown));
}
/* getFile('foobar', {
open: '<!-- bar -->',
close: '<!-- barstop -->',
regex: /(?:<!-- bar(?:\s*stop)? -->)/g
}); */
getMarkdown('foobar');