pretty printing HTML output (for nice git diffs)

This commit is contained in:
azivner 2017-12-03 09:19:48 -05:00
parent ddd216c92e
commit 41f089b3f4
3 changed files with 11 additions and 1 deletions

8
package-lock.json generated
View File

@ -4264,6 +4264,14 @@
"resolved": "https://registry.npmjs.org/hsts/-/hsts-2.1.0.tgz",
"integrity": "sha512-zXhh/DqgrTXJ7erTN6Fh5k/xjMhDGXCqdYN3wvxUvGUQvnxcFfUd8E+6vLg/nk3ss1TYMb+DhRl25fYABioTvA=="
},
"html": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/html/-/html-1.0.0.tgz",
"integrity": "sha1-pUT6nqVJK/s6LMqCEKEL57WvH2E=",
"requires": {
"concat-stream": "1.6.0"
}
},
"html-comment-regex": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/html-comment-regex/-/html-comment-regex-1.1.1.tgz",

View File

@ -25,6 +25,7 @@
"express-session": "^1.15.6",
"fs-extra": "^4.0.2",
"helmet": "^3.9.0",
"html": "^1.0.0",
"ini": "^1.3.4",
"request": "^2.83.0",
"request-promise": "^4.2.2",

View File

@ -6,6 +6,7 @@ const rimraf = require('rimraf');
const fs = require('fs');
const sql = require('../../services/sql');
const data_dir = require('../../services/data_dir');
const html = require('html');
router.get('/:noteId/to/:directory', async (req, res, next) => {
const noteId = req.params.noteId;
@ -36,7 +37,7 @@ async function exportNote(noteTreeId, dir) {
const pos = (noteTree.note_pos + '').padStart(4, '0');
fs.writeFileSync(dir + '/' + pos + '-' + note.note_title + '.html', note.note_text);
fs.writeFileSync(dir + '/' + pos + '-' + note.note_title + '.html', html.prettyPrint(note.note_text, {indent_size: 2}));
const children = await sql.getResults("SELECT * FROM notes_tree WHERE note_pid = ? AND is_deleted = 0", [note.note_id]);