Skip to content

Commit

Permalink
WIP: markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
marc1006 committed Jun 6, 2020
1 parent 232bc74 commit 1f85b25
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 33 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@ percolate:synced-cron
easylogic:summernote
cfs:filesystem
ostrio:cookies
tmeasday:check-npm-versions
3 changes: 2 additions & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 0 additions & 9 deletions packages/markdown/markdown.js

This file was deleted.

18 changes: 11 additions & 7 deletions packages/markdown/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
5 changes: 5 additions & 0 deletions packages/markdown/src/checkNpmVersions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { checkNpmVersions } from 'meteor/tmeasday:check-npm-versions';

checkNpmVersions({
'xss': '1.0.6',
}, 'my:xss');
9 changes: 9 additions & 0 deletions packages/markdown/src/markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import marked from '../marked/lib/marked.js';

marked.setOptions({
gfm: true,
tables: true,
breaks: true,
});

Markdown = marked;
18 changes: 18 additions & 0 deletions packages/markdown/src/template-integration.js
Original file line number Diff line number Diff line change
@@ -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)));
}));
}
16 changes: 0 additions & 16 deletions packages/markdown/template-integration.js

This file was deleted.

0 comments on commit 1f85b25

Please sign in to comment.