diff --git a/package-lock.json b/package-lock.json index c5c44b76..25c29776 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4263,15 +4263,6 @@ "@types/node": "*" } }, - "@types/highlight.js": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/@types/highlight.js/-/highlight.js-10.1.0.tgz", - "integrity": "sha512-77hF2dGBsOgnvZll1vymYiNUtqJ8cJfXPD6GG/2M0aLRc29PkvB7Au6sIDjIEFcSICBhCh2+Pyq6WSRS7LUm6A==", - "dev": true, - "requires": { - "highlight.js": "*" - } - }, "@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", diff --git a/package.json b/package.json index 96dc95da..6d1c036c 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -74,7 +74,7 @@ "typescript": "4.7.4" }, "peerDependencies": { - "highlight.js": "^10.0.3" + "highlight.js": "^10.0.3 || ^11" }, "peerDependenciesMeta": { "highlight.js": { diff --git a/test/__snapshots__/highlight-code.test.ts.snap b/test/__snapshots__/highlight-code.test.ts.snap new file mode 100644 index 00000000..7839e2bc --- /dev/null +++ b/test/__snapshots__/highlight-code.test.ts.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should highlight code 1`] = ` +"
const x: string = 'y';
+
+" +`; diff --git a/test/highlight-code.test.ts b/test/highlight-code.test.ts new file mode 100644 index 00000000..e0e5e3bd --- /dev/null +++ b/test/highlight-code.test.ts @@ -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(); +});