WIP: markdown

This commit is contained in:
Marc Hartmayer 2020-06-06 11:26:06 +02:00
parent 232bc746f4
commit 1f85b25549
8 changed files with 46 additions and 33 deletions

View file

@ -0,0 +1,5 @@
import { checkNpmVersions } from 'meteor/tmeasday:check-npm-versions';
checkNpmVersions({
'xss': '1.0.6',
}, 'my:xss');

View file

@ -0,0 +1,9 @@
import marked from '../marked/lib/marked.js';
marked.setOptions({
gfm: true,
tables: true,
breaks: true,
});
Markdown = marked;

View file

@ -0,0 +1,18 @@
import sanitizeXss from 'xss';
if (Package.ui) {
const Template = Package.templating.Template;
const UI = Package.ui.UI;
const HTML = Package.htmljs.HTML;
const Blaze = Package.blaze.Blaze; // implied by `ui`
UI.registerHelper('markdown', new Template('markdown', function () {
const self = this;
let text = '';
if (self.templateContentBlock) {
text = Blaze._toText(self.templateContentBlock, HTML.TEXTMODE.STRING);
}
return HTML.Raw(sanitizeXss(Markdown(text)));
}));
}