unify markdown mime to text/x-markdown

This commit is contained in:
zadam 2019-02-25 21:57:11 +01:00
parent 4b1cf05c0e
commit 003eed368b
3 changed files with 6 additions and 4 deletions

View File

@ -34,7 +34,7 @@ async function exportSingleNote(exportContext, branch, format, res) {
const turndownService = new TurndownService();
payload = turndownService.turndown(noteContent.content);
extension = 'md';
mime = 'text/markdown'
mime = 'text/x-markdown'
}
}
else if (note.type === 'code') {

View File

@ -28,6 +28,8 @@ const CODE_MIME_TYPES = {
'text/x-kotlin': true,
'text/x-stex': true,
'text/x-lua': true,
// possibly later migrate to text/markdown as primary MIME
'text/markdown': 'text/x-markdown',
'text/x-markdown': true,
'text/x-objectivec': true,
'text/x-pascal': true,
@ -48,7 +50,7 @@ async function importSingleFile(importContext, file, parentNote) {
if (importContext.textImportedAsText) {
if (file.mimetype === 'text/html') {
return await importHtml(importContext, file, parentNote);
} else if (file.mimetype === 'text/markdown') {
} else if (['text/markdown', 'text/x-markdown'].includes(file.mimetype)) {
return await importMarkdown(importContext, file, parentNote);
} else if (file.mimetype === 'text/plain') {
return await importPlainText(importContext, file, parentNote);

View File

@ -133,7 +133,7 @@ async function importTar(importContext, fileBuffer, importRootNote) {
let type = 'file';
if (mime) {
if (mime === 'text/html' || mime === 'text/markdown') {
if (mime === 'text/html' || ['text/markdown', 'text/x-markdown'].includes(mime)) {
type = 'text';
}
else if (mime.startsWith('image/')) {
@ -251,7 +251,7 @@ async function importTar(importContext, fileBuffer, importRootNote) {
}
}
if ((noteMeta && noteMeta.format === 'markdown') || (!noteMeta && mime === 'text/markdown')) {
if ((noteMeta && noteMeta.format === 'markdown') || (!noteMeta && ['text/markdown', 'text/x-markdown'].includes(mime))) {
const parsed = mdReader.parse(content);
content = mdWriter.render(parsed);
}