Skip to content

Commit 81c4d7b

Browse files
WestbrookdaKmoR
authored andcommitted
Use a more recently published prism converter for rehype
1 parent 0818119 commit 81c4d7b

File tree

12 files changed

+75
-126
lines changed

12 files changed

+75
-126
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@ First, create a fork of the [modernweb-dev/rocket](https://github.com/modernweb-
88

99
Next, clone our repository onto your computer.
1010

11-
```sh
11+
```shell
1212
git clone git@github.com:modernweb-dev/rocket.git
1313
```
1414

1515
Once cloning is complete, change directory to the repository.
1616

17-
```sh
17+
```shell
1818
cd rocket
1919
```
2020

2121
Now add your fork as a remote (replacing YOUR_USERNAME with your GitHub username).
2222

23-
```sh
23+
```shell
2424
git remote add fork git@github.com:<YOUR_USERNAME>/rocket.git
2525
```
2626

2727
Create a new local branch.
2828

29-
```sh
29+
```shell
3030
git checkout -b my-awesome-fix
3131
```
3232

3333
## Preparing Your Local Environment for Development
3434

3535
Now that you have cloned the repository, ensure you have [yarn](https://classic.yarnpkg.com/lang/en/) installed, then run the following commands to set up the development environment.
3636

37-
```sh
37+
```shell
3838
yarn install
3939
```
4040

@@ -69,7 +69,7 @@ This documents your intent to release, and allows you to specify a message that
6969

7070
Run
7171

72-
```sh
72+
```shell
7373
yarn changeset
7474
```
7575

@@ -92,15 +92,15 @@ Exceptions:
9292
Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/)
9393
Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this:
9494

95-
```sh
95+
```shell
9696
fix(test-runner): fix terrible bug
9797
```
9898

9999
## Create a Pull Request
100100

101101
Now it's time to push your branch that contains your committed changes to your fork.
102102

103-
```sh
103+
```shell
104104
git push -u fork my-awesome-fix
105105
```
106106

docs/blog/introducing-check-html-links.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ The features so far are:
140140

141141
It checks your final HTML output so you need to execute it after your Static Site Generator.
142142

143-
```
143+
```shell
144144
npx check-html-links _site
145145
```
146146

docs/docs/eleventy-plugins/mdjs-unified.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Use mdjs in your Eleventy site.
44

55
## Setup
66

7-
```
7+
```shell
88
npm install @rocket/eleventy-plugin-mdjs
99
```
1010

docs/docs/tools/check-html-links.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Read the [Introducing Check HTMl Links - no more bad links](../../blog/introduci
2222

2323
## Installation
2424

25-
```
25+
```shell
2626
npm i -D check-html-links
2727
```
2828

docs/guides/first-pages/manage-sidebar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Will be ordered as `First`, `Second`,
2323

2424
Internally `# Foo >> Bar >> Baz ||20` gets converted to.
2525

26-
```
26+
```yml
2727
---
2828
title: Bar: Baz
2929
eleventyNavigation:

packages/check-html-links/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ A fast checker for broken links/references in HTML.
44

55
## Installation
66

7-
```
7+
```shell
88
npm i -D check-html-links
99
```
1010

1111
## Usage
1212

13-
```
13+
```bash
1414
npx check-html-links _site
1515
```
1616

packages/mdjs-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"github-markdown-css": "^4.0.0",
5353
"plugins-manager": "^0.3.0",
5454
"rehype-autolink-headings": "^5.0.1",
55-
"rehype-prism-template": "^0.4.1",
55+
"rehype-prism": "^1.0.0",
5656
"rehype-raw": "^5.0.0",
5757
"rehype-slug": "^4.0.1",
5858
"rehype-stringify": "^8.0.0",

packages/mdjs-core/src/mdjsProcess.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ const raw = require('rehype-raw');
1212
const htmlStringify = require('rehype-stringify');
1313
const htmlSlug = require('rehype-slug');
1414
const htmlHeading = require('rehype-autolink-headings');
15-
const rehypePrism = require('rehype-prism-template');
1615
// @ts-ignore
1716
const { executeSetupFunctions } = require('plugins-manager');
17+
const loadLanguages = require('prismjs/components/');
1818

1919
const { mdjsParse } = require('./mdjsParse.js');
2020
const { mdjsStoryParse } = require('./mdjsStoryParse.js');
2121
const { mdjsSetupCode } = require('./mdjsSetupCode.js');
2222

23+
let prismLoaded = false;
24+
2325
/** @type {MdjsProcessPlugin[]} */
2426
const defaultMetaPlugins = [
2527
{ plugin: markdown, options: {} },
@@ -30,8 +32,6 @@ const defaultMetaPlugins = [
3032
// @ts-ignore
3133
{ plugin: remark2rehype, options: { allowDangerousHtml: true } },
3234
// @ts-ignore
33-
{ plugin: rehypePrism, options: {} },
34-
// @ts-ignore
3535
{ plugin: raw, options: {} },
3636
// @ts-ignore
3737
{ plugin: htmlSlug, options: {} },
@@ -54,6 +54,12 @@ const defaultMetaPlugins = [
5454
*/
5555
async function mdjsProcess(mdjs, { setupUnifiedPlugins = [] } = {}) {
5656
const parser = unified();
57+
if (!prismLoaded) {
58+
prismLoaded = true;
59+
const rehypePrism = (await import('rehype-prism/lib/src/index.js')).default;
60+
loadLanguages(['md', 'shell', 'yml']);
61+
defaultMetaPlugins.splice(6, 0, { plugin: rehypePrism, options: {} });
62+
}
5763

5864
const metaPlugins = executeSetupFunctions(setupUnifiedPlugins, defaultMetaPlugins);
5965

packages/mdjs-core/test-node/mdJsProcess.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('mdjsProcess', () => {
3535
'',
3636
'',
3737
'',
38-
'<pre class="language-js"><code class="language-js"><span class="token keyword module">export</span> <span class="token keyword">const</span> <span class="token function-variable function">fooPreviewStory</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span><span class="token punctuation">}</span>',
38+
'<pre class="language-js"><code class="language-js"><span class="token keyword">export</span> <span class="token keyword">const</span> <span class="token function-variable function">fooPreviewStory</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span><span class="token punctuation">}</span>',
3939
'</code></pre>',
4040
'',
4141
'',

packages/mdjs-core/types/remark.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ declare module 'rehype-autolink-headings' {
2828
export = unified.Plugin;
2929
}
3030

31-
declare module 'rehype-prism-template' {
32-
import unified from 'unified';
33-
34-
export = unified.Plugin;
35-
}
36-
3731
declare module 'unist-util-remove' {
3832
import unified from 'unified';
3933

0 commit comments

Comments
 (0)