Skip to content

Commit

Permalink
switch to markdown-it
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McGuinness committed Mar 24, 2015
1 parent 838fe38 commit fd8ecb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions gulp/utils/metalsmith.data.markdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Modified from: https://github.com/majodev/metalsmith-data-markdown

var marked = require('marked');
var MarkdownIt = require('markdown-it');
var md = new MarkdownIt();
var cheerio = require('cheerio');
var he = require('he');
var _ = require('lodash');
Expand Down Expand Up @@ -33,12 +34,9 @@ function plugin(options) {

var opts = options || {};

// set default options or args
opts.marked = opts.marked || {};
opts.removeAttributeAfterwards = opts.removeAttributeAfterwards || false;

// hand opts to marked
marked.setOptions(opts.marked);

return function(files, metalsmith, done) {
setImmediate(done);
Expand All @@ -58,9 +56,9 @@ function plugin(options) {
$('[data-markdown]').each(function() {

// grab the html of the node and
// decode all html entities (as marked doesn't have to know about them)
// decode all html entities
// decoding fixes problems with smartypants
var markedText = marked(he.decode($(this).html()));
var markedText = md.render(he.decode($(this).html()));

// set compiled markdown content to node
$(this).html(markedText);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"karma-phantomjs-launcher": "^0.1.4",
"karma-sauce-launcher": "^0.2.10",
"lodash": "^3.5.0",
"marked": "^0.3.3",
"markdown-it": "^4.0.2",
"metalsmith": "^1.0.1",
"metalsmith-collections": "^0.7.0",
"metalsmith-mock": "^1.0.0",
Expand Down

0 comments on commit fd8ecb8

Please sign in to comment.