Skip to content

Commit

Permalink
Add special case for remark-prism (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle authored Sep 16, 2021
1 parent 7b2a1d8 commit c73e38f
Show file tree
Hide file tree
Showing 4 changed files with 461 additions and 2 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@
"phantomjs-prebuilt": "^2.1.16",
"playwright-core": "^1.11.1",
"polyfill-library": "3.93.0",
"prismjs": "^1.24.1",
"pug": "^3.0.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"redis": "^3.1.1",
"remark-parse": "^10.0.0",
"remark-prism": "^1.3.6",
"rxjs": "^6.5.2",
"saslprep": "^1.0.3",
"semver": "^7.1.1",
Expand All @@ -120,6 +123,7 @@
"twilio": "^3.33.0",
"typescript": "^3.9.6",
"uglify-js": "^3.6.0",
"unified": "^10.1.0",
"vm2": "^3.8.2",
"vue": "^2.6.10",
"vue-server-renderer": "^2.6.10",
Expand Down
11 changes: 11 additions & 0 deletions src/utils/special-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ const specialCases: Record<string, (o: SpecialCaseOpts) => void> = {
emitAssetDirectory(resolve(dirname(id), '..', 'bin'));
}
},
'remark-prism' ({ id, emitAssetDirectory }) {
const file = 'remark-prism/src/highlight.js';
if (id.endsWith(file)) {
try {
const node_modules = id.slice(0, -file.length);
emitAssetDirectory(resolve(node_modules, 'prismjs', 'components'));
} catch (e) {
// fail silently
}
}
},
'semver' ({ id, emitAsset }) {
if (id.endsWith('semver/index.js')) {
// See https://github.com/npm/node-semver/blob/master/CHANGELOG.md#710
Expand Down
7 changes: 7 additions & 0 deletions test/integration/remark-prism.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { unified } from 'unified';
import parse from 'remark-parse';
import prism from 'remark-prism';

const engine = unified().use(parse).use(prism);
const ast = engine.parse('# markdown');
engine.runSync(ast);
Loading

0 comments on commit c73e38f

Please sign in to comment.