Skip to content

Build your personal knowledge base with Trilium Notes

unify markdown mime to text/x-markdown

zadam003eed368b89
diff --git a/src/services/export/single.js b/src/services/export/single.js
index 0e7c4dca92..3e14e485ce 100644
--- a/src/services/export/single.js
+++ b/src/services/export/single.js
@@ -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') {
diff --git a/src/services/import/single.js b/src/services/import/single.js
index 703e55a4a8..d513961ef6 100644
--- a/src/services/import/single.js
+++ b/src/services/import/single.js
@@ -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);
diff --git a/src/services/import/tar.js b/src/services/import/tar.js
index b092c3cc07..3b1eb1353c 100644
--- a/src/services/import/tar.js
+++ b/src/services/import/tar.js
@@ -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);
}