Skip to content

Commit

Permalink
Use remark subdeps directly for parsing, remove unnecessary try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Jacobs committed Sep 3, 2016
1 parent 3d59fac commit 06eb4c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 3 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import {parse} from 'remark';
import unified from 'unified';
import parser from 'remark-parse';

const getType = Object.prototype.toString;
const textTypes = ['text', 'textNode'];
Expand Down Expand Up @@ -350,14 +351,7 @@ export default function markdownToJSX(markdown, options = {}, overrides = {}) {
options.position = options.position || false;
options.footnotes = options.footnotes || true;

let remarkAST;

try {
remarkAST = parse(markdown, options);
} catch (error) {
return error;
}

const remarkAST = unified().use(parser).parse(markdown, options);
const extracted = extractDefinitionsFromASTTree(remarkAST);

definitions = extracted.definitions;
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"bugs": "https://github.com/yaycmyk/markdown-to-jsx/issues",
"main": "index.es5.js",
"jsnext:main": "index.js",
"module": "index.js",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-jest": "^15.0.0",
Expand All @@ -26,7 +27,8 @@
"jest-cli": "^15.1.1"
},
"dependencies": {
"remark": "^4.2.2"
"remark-parse": "^2.0.1",
"unified": "^5.0.0"
},
"peerDependencies": {
"react": ">= 0.14.0"
Expand Down

0 comments on commit 06eb4c6

Please sign in to comment.