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

@ -98,3 +98,4 @@ percolate:synced-cron
easylogic:summernote
cfs:filesystem
ostrio:cookies
tmeasday:check-npm-versions

View file

@ -177,6 +177,7 @@ templating@1.3.2
templating-compiler@1.3.3
templating-runtime@1.3.2
templating-tools@1.1.2
tmeasday:check-npm-versions@0.3.2
tracker@1.2.0
twbs:bootstrap@3.3.6
ui@1.0.13
@ -191,7 +192,7 @@ webapp-hashing@1.0.9
wekan-accounts-cas@0.1.0
wekan-accounts-oidc@1.0.10
wekan-ldap@0.0.2
wekan-markdown@1.0.8
wekan-markdown@1.0.9
wekan-oidc@1.0.12
wekan-scrollbar@3.1.3
yasaricli:slugify@0.0.7

View file

@ -1,9 +0,0 @@
var mark = marked;
mark.setOptions({
gfm: true,
tables: true,
breaks: true
});
Markdown = mark;

View file

@ -2,23 +2,27 @@
Package.describe({
name: 'wekan-markdown',
summary: "GitHub flavored markdown parser for Meteor based on marked.js",
version: "1.0.8",
git: "https://github.com/wekan/markdown.git"
summary: 'GitHub flavored markdown parser for Meteor based on marked.js',
version: '1.0.9',
git: 'https://github.com/wekan/markdown.git',
});
// Before Meteor 0.9?
if(!Package.onUse) Package.onUse = Package.on_use;
Package.onUse(function (api) {
if(api.versionsFrom) api.versionsFrom('METEOR@0.9.0');
if(api.versionsFrom) api.versionsFrom('1.8.2');
api.use('templating');
api.use("ecmascript", ['server', 'client']);
api.add_files('marked/lib/marked.js', ['server', 'client']);
api.add_files('markdown.js', ['server', 'client']);
api.add_files('src/markdown.js', ['server', 'client']);
api.export('Markdown', ['server', 'client']);
api.use("ui", "client", {weak: true});
api.add_files("template-integration.js", "client");
api.use('ui', 'client', {weak: true});
api.use('tmeasday:check-npm-versions', 'client');
api.add_files('src/checkNpmVersions.js', 'client');
api.add_files('src/template-integration.js', 'client');
});

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)));
}));
}

View file

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