Fix problem with missing syntax highlighting languages causing runtime crash on the website (#12781)

* Fix problem with universe pages using `docker` language

* Fix problem with universe pages using `r` language

* Add fallback, in case code language is unknown
This commit is contained in:
Marcus Blättermann 2023-07-03 10:24:25 +02:00 committed by GitHub
parent 57a230c6e4
commit bd239511a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,8 @@ import 'prismjs/components/prism-json.min.js'
import 'prismjs/components/prism-markdown.min.js'
import 'prismjs/components/prism-python.min.js'
import 'prismjs/components/prism-yaml.min.js'
import 'prismjs/components/prism-docker.min.js'
import 'prismjs/components/prism-r.min.js'
import { isString } from './util'
import Link, { OptionalLink } from './link'
@ -172,7 +174,7 @@ const convertLine = ({ line, prompt, lang }) => {
return handlePromot({ lineFlat, prompt })
}
return lang === 'none' || !lineFlat ? (
return lang === 'none' || !lineFlat || !(lang in Prism.languages) ? (
lineFlat
) : (
<span