Node.js based forum software built for the modern web
feat: introduce new 'markdown' post parsing type, closes #13077
Julian Lamb386e4a66e81
diff --git a/install/package.json b/install/package.jsonindex d15878f3eb..84c0521bf2 100644--- a/install/package.json+++ b/install/package.json@@ -103,8 +103,8 @@"nodebb-plugin-dbsearch": "6.2.5","nodebb-plugin-emoji": "6.0.1","nodebb-plugin-emoji-android": "4.1.1",- "nodebb-plugin-markdown": "13.0.0",- "nodebb-plugin-mentions": "4.6.10",+ "nodebb-plugin-markdown": "13.1.0",+ "nodebb-plugin-mentions": "4.7.0","nodebb-plugin-spam-be-gone": "2.3.0","nodebb-plugin-web-push": "0.7.2","nodebb-rewards-essentials": "1.0.0",diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.jsindex 95274fae89..0c17f83304 100644--- a/src/activitypub/mocks.js+++ b/src/activitypub/mocks.js@@ -436,7 +436,7 @@ Mocks.notes.public = async (post) => {}const content = await posts.getPostField(post.pid, 'content');- post.content = content; // re-send raw content+ post.content = content; // re-send raw content into parsePostconst parsed = await posts.parsePost(post, 'activitypub.note');post.content = sanitize(parsed.content, sanitizeConfig);post.content = posts.relativeToAbsolute(post.content, posts.urlRegex);@@ -448,9 +448,13 @@ Mocks.notes.public = async (post) => {plugins.isActive('nodebb-plugin-mentions'),]);if (markdownEnabled) {+ // Re-parse for markdown+ const _post = { ...post };const raw = await posts.getPostField(post.pid, 'content');+ _post.content = raw;+ const { content } = await posts.parsePost(_post, 'markdown');source = {- content: raw,+ content,mediaType: 'text/markdown',};}diff --git a/src/posts/parse.js b/src/posts/parse.jsindex fcc87b1ecd..7f5f0bd518 100644--- a/src/posts/parse.js+++ b/src/posts/parse.js@@ -33,7 +33,7 @@ let sanitizeConfig = {'tabindex', 'title', 'translate', 'aria-*', 'data-*',],};-const allowedTypes = new Set(['default', 'plaintext', 'activitypub.note', 'activitypub.article']);+const allowedTypes = new Set(['default', 'plaintext', 'activitypub.note', 'activitypub.article', 'markdown']);module.exports = function (Posts) {Posts.urlRegex = {