Theme-ui: Unsupported Prism Languages

Created on 5 Jul 2019  路  3Comments  路  Source: system-ui/theme-ui

@theme-ui/prism uses prism-react-renderer, which does not include all languages supported by Prism by default. So if you use one of the missing languages, it simply does not highlight:

# r language
# no syntax highlighting on theme-ui

A fix would be to pass Prism as a prop on Highlight component, as documented here. I think the best approach would be to allow passing Prism to index.js like this:

export default ({ children, className, title, Prism }) => {
  // ...

  return (
    <Highlight
      {...defaultProps} 
      Prism={Prism || defaultProps.Prism}
      ... />
  )
}

So that it could be customized like:

import CodeBlock from '@theme-ui/prism'
import Prism from 'prismjs/components/prism-core'
import 'prismjs/components/prism-r'

<CodeBlock Prism={Prism} ... />

All 3 comments

@jxnblk @johno Just following up on this issue, should we maybe add to the documentation noting how since prism-react-renderer doesn't support all languages, we have added the ability to import custom language syntax highlighting? So that future users, when coming across this problem, can look at the documentation?

It鈥檚 worth noting on the readme for sure 馃憤

Great ... I will open a PR!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mxstbr picture mxstbr  路  3Comments

johno picture johno  路  3Comments

VinSpee picture VinSpee  路  3Comments

LeunensMichiel picture LeunensMichiel  路  3Comments

8eecf0d2 picture 8eecf0d2  路  3Comments