mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: introduce new 'markdown' post parsing type, closes #13077
This commit is contained in:
@@ -103,8 +103,8 @@
|
|||||||
"nodebb-plugin-dbsearch": "6.2.5",
|
"nodebb-plugin-dbsearch": "6.2.5",
|
||||||
"nodebb-plugin-emoji": "6.0.1",
|
"nodebb-plugin-emoji": "6.0.1",
|
||||||
"nodebb-plugin-emoji-android": "4.1.1",
|
"nodebb-plugin-emoji-android": "4.1.1",
|
||||||
"nodebb-plugin-markdown": "13.0.0",
|
"nodebb-plugin-markdown": "13.1.0",
|
||||||
"nodebb-plugin-mentions": "4.6.10",
|
"nodebb-plugin-mentions": "4.7.0",
|
||||||
"nodebb-plugin-spam-be-gone": "2.3.0",
|
"nodebb-plugin-spam-be-gone": "2.3.0",
|
||||||
"nodebb-plugin-web-push": "0.7.2",
|
"nodebb-plugin-web-push": "0.7.2",
|
||||||
"nodebb-rewards-essentials": "1.0.0",
|
"nodebb-rewards-essentials": "1.0.0",
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ Mocks.notes.public = async (post) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const content = await posts.getPostField(post.pid, 'content');
|
const content = await posts.getPostField(post.pid, 'content');
|
||||||
post.content = content; // re-send raw content
|
post.content = content; // re-send raw content into parsePost
|
||||||
const parsed = await posts.parsePost(post, 'activitypub.note');
|
const parsed = await posts.parsePost(post, 'activitypub.note');
|
||||||
post.content = sanitize(parsed.content, sanitizeConfig);
|
post.content = sanitize(parsed.content, sanitizeConfig);
|
||||||
post.content = posts.relativeToAbsolute(post.content, posts.urlRegex);
|
post.content = posts.relativeToAbsolute(post.content, posts.urlRegex);
|
||||||
@@ -448,9 +448,13 @@ Mocks.notes.public = async (post) => {
|
|||||||
plugins.isActive('nodebb-plugin-mentions'),
|
plugins.isActive('nodebb-plugin-mentions'),
|
||||||
]);
|
]);
|
||||||
if (markdownEnabled) {
|
if (markdownEnabled) {
|
||||||
|
// Re-parse for markdown
|
||||||
|
const _post = { ...post };
|
||||||
const raw = await posts.getPostField(post.pid, 'content');
|
const raw = await posts.getPostField(post.pid, 'content');
|
||||||
|
_post.content = raw;
|
||||||
|
const { content } = await posts.parsePost(_post, 'markdown');
|
||||||
source = {
|
source = {
|
||||||
content: raw,
|
content,
|
||||||
mediaType: 'text/markdown',
|
mediaType: 'text/markdown',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ let sanitizeConfig = {
|
|||||||
'tabindex', 'title', 'translate', 'aria-*', 'data-*',
|
'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) {
|
module.exports = function (Posts) {
|
||||||
Posts.urlRegex = {
|
Posts.urlRegex = {
|
||||||
|
|||||||
Reference in New Issue
Block a user