note content refactoring, WIP

This commit is contained in:
zadam
2019-02-06 21:29:23 +01:00
parent 8884177d9f
commit c487a95bc7
17 changed files with 158 additions and 123 deletions

View File

@@ -18,30 +18,32 @@ async function exportSingleNote(branch, format, res) {
let payload, extension, mime;
const noteContent = await note.getNoteContent();
if (note.type === 'text') {
if (format === 'html') {
if (!note.content.toLowerCase().includes("<html")) {
note.content = '<html><head><meta charset="utf-8"></head><body>' + note.content + '</body></html>';
if (!noteContent.content.toLowerCase().includes("<html")) {
noteContent.content = '<html><head><meta charset="utf-8"></head><body>' + noteContent.content + '</body></html>';
}
payload = html.prettyPrint(note.content, {indent_size: 2});
payload = html.prettyPrint(noteContent.content, {indent_size: 2});
extension = 'html';
mime = 'text/html';
}
else if (format === 'markdown') {
const turndownService = new TurndownService();
payload = turndownService.turndown(note.content);
payload = turndownService.turndown(noteContent.content);
extension = 'md';
mime = 'text/markdown'
}
}
else if (note.type === 'code') {
payload = note.content;
payload = noteContent.content;
extension = mimeTypes.extension(note.mime) || 'code';
mime = note.mime;
}
else if (note.type === 'relation-map' || note.type === 'search') {
payload = note.content;
payload = noteContent.content;
extension = 'json';
mime = 'application/json';
}