diff --git a/meteor/post.js b/meteor/post.js new file mode 100644 index 000000000..1c9e7ca05 --- /dev/null +++ b/meteor/post.js @@ -0,0 +1,4 @@ +MarkdownIt = module.exports; +markdownIt = new MarkdownIt({ + linkify: true +}); diff --git a/meteor/pre.js b/meteor/pre.js new file mode 100644 index 000000000..e2eaf40e2 --- /dev/null +++ b/meteor/pre.js @@ -0,0 +1,2 @@ +exports = {}; +module = {}; diff --git a/meteor/template-helper.js b/meteor/template-helper.js new file mode 100644 index 000000000..8cd18acfa --- /dev/null +++ b/meteor/template-helper.js @@ -0,0 +1,16 @@ +if (!Package.templating) { + return; +} + +var Blaze = Package.blaze.Blaze; +var HTML = Package.htmljs.HTML; +var Template = Package.templating.Template; + +Template.registerHelper('markdown', new Template('markdown', function() { + var view = this; + var content = ''; + if (view.templateContentBlock) { + content = Blaze._toText(view.templateContentBlock, HTML.TEXTMODE.STRING); + } + return HTML.Raw(markdownIt.render(content)); +})); diff --git a/package.js b/package.js new file mode 100644 index 000000000..b1f831196 --- /dev/null +++ b/package.js @@ -0,0 +1,27 @@ +Package.describe({ + git: 'https://github.com/hansoft/markdown-it.git', + name: 'hansoft:markdown-it', + summary: 'Markdown parser done right. Fast and easy to extend.', + version: '5.0.2' +}); + +Package.onUse(function(api) { + api.versionsFrom("METEOR@2.3"); + + api.use([ + 'templating' + ], { weak: true }); + + api.export([ + 'MarkdownIt', + 'markdownIt' + ]); + + api.addFiles([ + 'meteor/pre.js', + 'dist/markdown-it.js', + 'meteor/post.js' + ]); + + api.addFiles('meteor/template-helper.js', 'client'); +}); diff --git a/package.json b/package.json index 194439e3b..8bbab4c2f 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ ], "dependencies": { "argparse": "^2.0.1", - "entities": "~3.0.1", + "entities": "~4.5.0", "linkify-it": "^4.0.1", "mdurl": "^1.0.1", "uc.micro": "^1.0.5"