replaced commonmark with micromark and gfm support

This commit is contained in:
unknown 2021-08-17 15:10:44 +05:30
parent 59226365c5
commit f49048c6e1
5 changed files with 662 additions and 100 deletions

View file

@ -1,5 +1,6 @@
import EventEmitter from 'events';
import { Parser, HtmlRenderer } from 'commonmark';
import { micromark } from 'micromark';
import { gfm, gfmHtml } from 'micromark-extension-gfm';
import encrypt from 'browser-encrypt-attachment';
import cons from './cons';
import settings from './settings';
@ -81,10 +82,11 @@ function getVideoThumbnail(video, width, height, mimeType) {
}
function getFormattedBody(markdown) {
const reader = new Parser();
const writer = new HtmlRenderer();
const parsed = reader.parse(markdown);
return writer.render(parsed);
const result = micromark(markdown, {
extensions: [gfm()],
htmlExtensions: [gfmHtml],
});
return result;
}
function getReplyFormattedBody(roomId, reply) {