From 651543661919d8ab819756f9f1127c8368b407bf Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Thu, 21 Oct 2021 13:09:32 +0200 Subject: [PATCH] docs: upgrade highlightjs to 11.x (#979) --- docs/content/en/configuration.md | 8 ++++---- docs/content/en/snippets.md | 4 ++-- docs/content/fr/snippets.md | 2 +- package.json | 2 +- packages/content/test/highlighter.spec.js | 12 ++++++------ yarn.lock | 8 ++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/content/en/configuration.md b/docs/content/en/configuration.md index 3a5fbd731..623550317 100644 --- a/docs/content/en/configuration.md +++ b/docs/content/en/configuration.md @@ -315,7 +315,7 @@ export default { content: { markdown: { highlighter(rawCode, lang) { - const highlightedCode = highlightjs.highlight(lang, rawCode).value + const highlightedCode = highlightjs.highlight(rawCode, { language: lang }).value // We need to create a wrapper, because // the returned code from highlight.js @@ -348,7 +348,7 @@ export default { content: { markdown: { highlighter(rawCode, lang, _, { h, node, u }) { - const highlightedCode = highlightjs.highlight(lang, rawCode).value + const highlightedCode = highlightjs.highlight(rawCode, { language: lang }).value // We can use ast helper to create the wrapper const childs = [] @@ -393,7 +393,7 @@ export default { content: { markdown: { highlighter(rawCode, lang, { lineHighlights, fileName }, { h, node, u }) { - const highlightedCode = highlightjs.highlight(lang, rawCode).value + const highlightedCode = highlightjs.highlight(rawCode, { language: lang }).value const childs = [] const props = { @@ -447,7 +447,7 @@ export default { const highlighter = await getHighlighter() return (rawCode, lang) => { - return highlighter.highlight(rawCode, lang) + return highlighter.highlight(rawCode, { language: lang }) } } } diff --git a/docs/content/en/snippets.md b/docs/content/en/snippets.md index 68ca7897e..dce21217b 100644 --- a/docs/content/en/snippets.md +++ b/docs/content/en/snippets.md @@ -280,7 +280,7 @@ export default { if (!lang) { return wrap(highlightjs.highlightAuto(rawCode).value, lang) } - return wrap(highlightjs.highlight(lang, rawCode).value, lang) + return wrap(highlightjs.highlight(rawCode, { language: lang }).value, lang) } } } @@ -377,7 +377,7 @@ module.exports = function () { 'https://api.github.com/repos/nuxt/content/contributors' ).then(res => res.json()) .then(res => res.map(({ login }) => login)) - + data.$contributors = [...new Set(contributors)] } return tree diff --git a/docs/content/fr/snippets.md b/docs/content/fr/snippets.md index eab75bc1a..cf43307b4 100644 --- a/docs/content/fr/snippets.md +++ b/docs/content/fr/snippets.md @@ -230,7 +230,7 @@ export default { if (!lang) { return wrap(highlightjs.highlightAuto(rawCode).value, lang) } - return wrap(highlightjs.highlight(lang, rawCode).value, lang) + return wrap(highlightjs.highlight(rawCode, { language: lang }).value, lang) } } } diff --git a/package.json b/package.json index 3e0ef6d61..b3e6b6280 100755 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "babel-jest": "^27.3.1", "codecov": "^3.8.1", "eslint": "^7.21.0", - "highlight.js": "^10.6.0", + "highlight.js": "^11.3.1", "jest": "^27.3.1", "lerna": "^4.0.0", "nuxt-edge": "latest", diff --git a/packages/content/test/highlighter.spec.js b/packages/content/test/highlighter.spec.js index cfa6b01a1..2896afe31 100644 --- a/packages/content/test/highlighter.spec.js +++ b/packages/content/test/highlighter.spec.js @@ -67,7 +67,7 @@ describe("highlighter", () => { ) } return wrapHighlightjs( - highlightjs.highlight(lang, rawCode).value, + highlightjs.highlight(rawCode, { language: lang }).value, lang ) } @@ -95,10 +95,10 @@ describe("highlighter", () => { test("renders correctly", () => { expect(nuxtContent).toMatchInlineSnapshot(` - "
console.log('Highlighter')
+        "
console.log('Highlighter')
         
// @errors: 2322
-        function sum(a: number, b: number): string {
+        function sum(a: number, b: number): string {
           return true
         }
         
" @@ -246,7 +246,7 @@ describe("highlighter", () => { if (!lang || lang === "null") { code = highlightjs.highlightAuto(rawCode).value } else { - code = highlightjs.highlight(lang, rawCode).value + code = highlightjs.highlight(rawCode, { language: lang }).value } return h( node, @@ -282,10 +282,10 @@ describe("highlighter", () => { test("renders correctly", () => { expect(nuxtContent).toMatchInlineSnapshot(` - "
console.log('Highlighter')
+        "
console.log('Highlighter')
         
// @errors: 2322
-        function sum(a: number, b: number): string {
+        function sum(a: number, b: number): string {
           return true
         }
         
" diff --git a/yarn.lock b/yarn.lock index 48d36908c..4dafa1fb7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8342,10 +8342,10 @@ hex-color-regex@^1.1.0: resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e" integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ== -highlight.js@^10.6.0: - version "10.7.3" - resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.3.tgz#697272e3991356e40c3cac566a74eef681756531" - integrity sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A== +highlight.js@^11.3.1: + version "11.3.1" + resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.3.1.tgz#813078ef3aa519c61700f84fe9047231c5dc3291" + integrity sha512-PUhCRnPjLtiLHZAQ5A/Dt5F8cWZeMyj9KRsACsWT+OD6OP0x6dp5OmT5jdx0JgEyPxPZZIPQpRN2TciUT7occw== hmac-drbg@^1.0.1: version "1.0.1"