Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: upgrade highlightjs to 11.x #979

Merged
merged 1 commit into from Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/content/en/configuration.md
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -447,7 +447,7 @@ export default {
const highlighter = await getHighlighter()

return (rawCode, lang) => {
return highlighter.highlight(rawCode, lang)
return highlighter.highlight(rawCode, { language: lang })
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/snippets.md
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/content/fr/snippets.md
Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions packages/content/test/highlighter.spec.js
Expand Up @@ -67,7 +67,7 @@ describe("highlighter", () => {
)
}
return wrapHighlightjs(
highlightjs.highlight(lang, rawCode).value,
highlightjs.highlight(rawCode, { language: lang }).value,
lang
)
}
Expand Down Expand Up @@ -95,10 +95,10 @@ describe("highlighter", () => {

test("renders correctly", () => {
expect(nuxtContent).toMatchInlineSnapshot(`
"<div class=\\"nuxt-content-highlight\\"><pre><code class=\\"hljs js\\"><span class=\\"hljs-built_in\\">console</span>.log(<span class=\\"hljs-string\\">'Highlighter'</span>)
"<div class=\\"nuxt-content-highlight\\"><pre><code class=\\"hljs js\\"><span class=\\"hljs-variable language_\\">console</span>.<span class=\\"hljs-title function_\\">log</span>(<span class=\\"hljs-string\\">'Highlighter'</span>)
</code></pre></div>
<div class=\\"nuxt-content-highlight\\"><pre><code class=\\"hljs typescript\\"><span class=\\"hljs-comment\\">// @errors: 2322</span>
<span class=\\"hljs-function\\"><span class=\\"hljs-keyword\\">function</span> <span class=\\"hljs-title\\">sum</span>(<span class=\\"hljs-params\\">a: <span class=\\"hljs-built_in\\">number</span>, b: <span class=\\"hljs-built_in\\">number</span></span>): <span class=\\"hljs-title\\">string</span> </span>{
<span class=\\"hljs-keyword\\">function</span> <span class=\\"hljs-title function_\\">sum</span>(<span class=\\"hljs-params\\">a: <span class=\\"hljs-built_in\\">number</span>, b: <span class=\\"hljs-built_in\\">number</span></span>): <span class=\\"hljs-built_in\\">string</span> {
<span class=\\"hljs-keyword\\">return</span> <span class=\\"hljs-literal\\">true</span>
}
</code></pre></div>"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -282,10 +282,10 @@ describe("highlighter", () => {

test("renders correctly", () => {
expect(nuxtContent).toMatchInlineSnapshot(`
"<div class=\\"highlighted-using-highlightjs\\"><pre><code class=\\"hljs undefined\\"><span class=\\"hljs-built_in\\">console</span>.log(<span class=\\"hljs-string\\">'Highlighter'</span>)
"<div class=\\"highlighted-using-highlightjs\\"><pre><code class=\\"hljs undefined\\"><span class=\\"hljs-variable language_\\">console</span>.<span class=\\"hljs-title function_\\">log</span>(<span class=\\"hljs-string\\">'Highlighter'</span>)
</code></pre></div>
<div data-line=\\"1\\" class=\\"highlighted-using-highlightjs index.ts\\"><pre><code class=\\"hljs undefined\\"><span class=\\"hljs-comment\\">// @errors: 2322</span>
<span class=\\"hljs-function\\"><span class=\\"hljs-keyword\\">function</span> <span class=\\"hljs-title\\">sum</span>(<span class=\\"hljs-params\\">a: <span class=\\"hljs-built_in\\">number</span>, b: <span class=\\"hljs-built_in\\">number</span></span>): <span class=\\"hljs-title\\">string</span> </span>{
<span class=\\"hljs-keyword\\">function</span> <span class=\\"hljs-title function_\\">sum</span>(<span class=\\"hljs-params\\">a: <span class=\\"hljs-built_in\\">number</span>, b: <span class=\\"hljs-built_in\\">number</span></span>): <span class=\\"hljs-built_in\\">string</span> {
<span class=\\"hljs-keyword\\">return</span> <span class=\\"hljs-literal\\">true</span>
}
</code></pre></div>"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -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"
Expand Down