Skip to content

Commit

Permalink
added dynamic install of marked, + DRYed parse method
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjmhart committed Jan 20, 2019
1 parent 99ca23d commit 7c0d812
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# heading1

content content content
1 change: 0 additions & 1 deletion packages/core/parcel-bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"is-url": "^1.2.2",
"js-yaml": "^3.10.0",
"json5": "^1.0.1",
"marked": "^0.6.0",
"micromatch": "^3.0.4",
"mkdirp": "^0.5.1",
"node-forge": "^0.7.1",
Expand Down
10 changes: 3 additions & 7 deletions packages/core/parcel-bundler/src/assets/MarkdownAsset.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
const marked = require('marked');
const posthtmlTransform = require('../transforms/posthtml');
const api = require('posthtml/lib/api');
const localRequire = require('../utils/localRequire');
const HTMLAsset = require('./HTMLAsset');

class MarkdownAsset extends HTMLAsset {
async parse(code) {
let res = await posthtmlTransform.parse(marked(code), this);
res.walk = api.walk;
res.match = api.match;
return res;
let marked = await localRequire('marked', this.name);
return HTMLAsset.prototype.parse.bind(this)(marked(code));
}
}

Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6717,11 +6717,6 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

marked@0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.6.0.tgz#a18d01cfdcf8d15c3c455b71c8329e5e0f01faa1"
integrity sha512-HduzIW2xApSXKXJSpCipSxKyvMbwRRa/TwMbepmlZziKdH8548WSoDP4SxzulEKjlo8BE39l+2fwJZuRKOln6g==

"match-stream@>= 0.0.2 < 1":
version "0.0.2"
resolved "https://registry.yarnpkg.com/match-stream/-/match-stream-0.0.2.tgz#99eb050093b34dffade421b9ac0b410a9cfa17cf"
Expand Down

0 comments on commit 7c0d812

Please sign in to comment.