diff --git a/lib/index.coffee b/lib/index.coffee index 5ae5607..6c832e3 100644 --- a/lib/index.coffee +++ b/lib/index.coffee @@ -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' @@ -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( @@ -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\\. ') diff --git a/package.json b/package.json index 5577549..f8871ef 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/index.coffee b/test/index.coffee index 567fc76..dff6f68 100644 --- a/test/index.coffee +++ b/test/index.coffee @@ -10,19 +10,6 @@ describe 'headings', -> tidyMdSnippet('
code
').should.equal('`code`')
@@ -534,7 +528,7 @@ describe 'tables', ->
''').should.equal('''
Name | Type | Description | Choices
------------------ | ------- | ---------------- | -------
- creator_license_id | unknown | License which...
+ creator_license_id | unknown | License which... |
''')
@@ -543,14 +537,14 @@ describe 'tables', ->
Name | Type | Description | Choices
:----| :----: | ------------- | ------:
0,0 | 0,1 | 0,2
- | 1,1 | 1,2 | | |
+ | 1,1 | 1,2 | | |
2,0 | 2,1 | | 2,3
''').should.equal('''
Name | Type | Description | Choices
:--- | :--: | ----------- | ------:
- 0,0 | 0,1 | 0,2
- | 1,1 | 1,2 | | |
+ 0,0 | 0,1 | 0,2 |
+ | 1,1 | 1,2 | |
2,0 | 2,1 | | 2,3
''')