diff --git a/lib/markdown-parser.js b/lib/markdown-parser.js index f1126055fe8d57852318fa3f7169897d34e57624..56c7e2d48c948993094f5f55c078b98e1997db8f 100644 --- a/lib/markdown-parser.js +++ b/lib/markdown-parser.js @@ -30,30 +30,35 @@ module.exports = function markdownParser(src) { const options = { gfm: true, - renderer: { - strong() {}, - em() {}, - codespan() {}, - br() {}, - del() {}, - link() {}, - image() {}, - text(text) { - text = text.replace(/'/g, "'"); - const roughSplit = text.split( - /(https?|ftp):\/\/[^\s/$.?#].[^\s]*|[\s\xa0\r\n]|&[a-z#0-9]+;|[&<>]/ - ); - for (let i = 0; i < roughSplit.length; i++) { - const split = roughSplit[i]; - if (split) { - addToken(split); - } + }; + const renderer = { + strong() {}, + em() {}, + codespan() {}, + br() {}, + del() {}, + link() {}, + image() {}, + text(text) { + text = text.replace(/'/g, "'"); + const roughSplit = text.split( + /(https?|ftp):\/\/[^\s/$.?#].[^\s]*|[\s\xa0\r\n]|&[a-z#0-9]+;|[&<>]/ + ); + for (let i = 0; i < roughSplit.length; i++) { + const split = roughSplit[i]; + if (split) { + addToken(split); } } } }; + marked.use({renderer}) + function addToken(text) { + if (text === "Link!") { + console.log("oh no") + } const newIndex = src.indexOf(text, currentIndex); if (newIndex === -1) { throw new Error( @@ -68,15 +73,9 @@ module.exports = function markdownParser(src) { textTokens.push({ text: text, index: tracker.getOriginalIndex(newIndex) }); } - const tokens = marked.lexer(src, options); - const inlineLexer = new marked.InlineLexer(tokens.links, options); + marked(src, options); + - for (let i = 0; i < tokens.length; i++) { - const token = tokens[i]; - if (token.text && token.type !== 'code') { - inlineLexer.output(token.text); - } - } return textTokens; }; diff --git a/package.json b/package.json index ffa9edcdff67d83bf0bcd623a03fb0626dbaaf3e..af0a7f827f32ade86205cd38fa83b412aaa47350 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "globby": "11.0.2", "inquirer": "8.0.0", "js-yaml": "3.14.1", - "marked": "0.8.0", + "marked": "2.0.1", "nspell": "2.1.5", "semver-regex": "3.1.2" }, diff --git a/yarn.lock b/yarn.lock index aaaf76f17bc12ea70c5576d79268b1a056e23ecb..17b271b96cf7eee2de96d24202bbb4fe393d102f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3005,10 +3005,10 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -marked@0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.0.tgz#ec5c0c9b93878dc52dd54be8d0e524097bd81a99" - integrity sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ== +marked@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/marked/-/marked-2.0.1.tgz#5e7ed7009bfa5c95182e4eb696f85e948cefcee3" + integrity sha512-5+/fKgMv2hARmMW7DOpykr2iLhl0NgjyELk5yn92iE7z8Se1IS9n3UsFm86hFXIkvMBmVxki8+ckcpjBeyo/hw== merge-stream@^2.0.0: version "2.0.0"