Skip to content

Commit

Permalink
feat: add highlight.js@11 to peerDependencies (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov authored Aug 30, 2023
1 parent 9be21ab commit d3c1869
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@babel/plugin-transform-modules-commonjs": "7.18.6",
"@babel/preset-env": "7.18.10",
"@types/github-slugger": "1.3.0",
"@types/highlight.js": "10.1.0",
"@types/jest": "28.1.7",
"@types/js-yaml": "^4.0.5",
"@types/lodash": "4.14.183",
Expand All @@ -64,6 +63,7 @@
"esbuild-sass-plugin": "^2.12.0",
"eslint": "8.22.0",
"eslint-plugin-security": "1.5.0",
"highlight.js": "^11.8.0",
"jest": "28.1.3",
"markdown-it-testgen": "^0.1.6",
"postcss": "^8.4.27",
Expand All @@ -74,7 +74,7 @@
"typescript": "4.7.4"
},
"peerDependencies": {
"highlight.js": "^10.0.3"
"highlight.js": "^10.0.3 || ^11"
},
"peerDependenciesMeta": {
"highlight.js": {
Expand Down
7 changes: 7 additions & 0 deletions test/__snapshots__/highlight-code.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should highlight code 1`] = `
"<pre><code class=\\"hljs ts\\"><span class=\\"hljs-keyword\\">const</span> <span class=\\"hljs-attr\\">x</span>: <span class=\\"hljs-built_in\\">string</span> = <span class=\\"hljs-string\\">&#x27;y&#x27;</span>;
</code></pre>
"
`;
20 changes: 20 additions & 0 deletions test/highlight-code.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {dirname} from 'path';
import transform from '../src/transform';

const mocksPath = require.resolve('./utils.ts');
const transformYfm = (text: string) => {
const {
result: {html},
} = transform(text, {
plugins: [],
path: mocksPath,
root: dirname(mocksPath),
});
return html;
};

test('should highlight code', () => {
const result = transformYfm("```ts\nconst x: string = 'y';\n```");

expect(result).toMatchSnapshot();
});

0 comments on commit d3c1869

Please sign in to comment.