Skip to content

Commit

Permalink
switch to a common-markdown parser
Browse files Browse the repository at this point in the history
  • Loading branch information
notslang committed Mar 30, 2016
1 parent ecead4b commit 32bbbf4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/index.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
fm = require 'front-matter'
marked = require 'marked'
md = require('markdown-it')(
html: true
linkify: true
)
yaml = require 'js-yaml'
{parseFragment, treeAdapters} = require 'parse5'

Expand Down Expand Up @@ -236,9 +239,10 @@ module.exports = (dirtyMarkdown, options = {}) ->
if Object.keys(content.attributes).length isnt 0
out += '---\n' + yaml.safeDump(content.attributes).trim() + '\n---\n\n'

ast = marked.lexer(content.body)
env = {}
ast = md.parse(content.body, env)

rawLinks = ast.links # see issue: https://github.com/chjj/marked/issues/472
rawLinks = env.references
links = []
for link, value of rawLinks
links.push(
Expand All @@ -247,7 +251,7 @@ module.exports = (dirtyMarkdown, options = {}) ->
title: value.title or null
)

html = marked.parser(ast)
html = md.renderer.render(ast, md.options, env)

# Escape potential ol triggers
html = html.replace(/(\d+)\. /g, '$1\\. ')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"indent": "0.0.2",
"js-yaml": "^3.2.7",
"lodash": "^4.5.0",
"marked": "0.3.2",
"markdown-it": "^6.0.0",
"pad": "0.0.5",
"parse5": "^2.1.5"
},
Expand Down

0 comments on commit 32bbbf4

Please sign in to comment.