unpack-whenwe-json.js - convert html to markdown
This commit is contained in:
@@ -7,5 +7,8 @@
|
|||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"node-html-markdown": "^1.3.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
const data = require('./whenwe.json');
|
const data = require('./whenwe.json');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } = require('node-html-markdown');
|
||||||
|
const nhm = new NodeHtmlMarkdown();
|
||||||
|
|
||||||
function toYaml(data, body) {
|
function toYaml(data, body) {
|
||||||
const frontmatter = Object.keys(data).sort().map(key => key+': '+(data[key] ?? '')).join("\n");
|
const frontmatter = Object.keys(data).sort().map(key => key+': '+(data[key] ?? '')).join("\n");
|
||||||
return frontmatter + "\n---\n" + body;
|
return frontmatter + "\n---\n" + nhm.translate(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
function date(datestr) {
|
function date(datestr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user