Does Docz support syntax highlighting outside of Playground?
See original GitHub issueQuestion
Does Docz support syntax highlighting outside of the Playground component?
Description
In addition to adding React component documentation, I am using Docz to document an entire system, at least half of which has nothing to do with React. Therefore, I need the ability to add “other” code snippets with the appropriate syntax highlighting.
For example, this does not seem to work:
Inside my file.mdx:
It produces the following in the docz-theme-default
theme:
The syntax highlighting for SCSS is not working. Syntax highlighting outside of the Playground, in general, does not work well, even for Javascript snippets.
Am I doing something wrong? Does Docz support this? Or maybe this is an MDX problem?
If this does not work, how can I help?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to get syntax highlighting to work? #1292 - doczjs/docz
I have just migrated my docz to V2 and the syntax highlighting (outside Playground) is no longer working (it was working earlier in...
Read more >Code blocks | Docusaurus
Use the matching language meta string for your code block, and Docusaurus will pick up syntax highlighting automatically, powered by Prism ...
Read more >How to Use Syntax Highlighting with TinaMarkdown - Tina.io
Today we are going to walk you through how to use syntax highlighting with TinaMarkdown. Through a very basic setup and example we...
Read more >Syntax Highlighting | Hugo
Highlighting is carried out via the built-in highlight shortcode. It takes exactly one required parameter for the programming language to be highlighted and ......
Read more >Syntax Highlighting - Tree-sitter
The Tree-sitter syntax highlighting system can help you to achieve this by keeping track of local scopes and variables. The local variables query...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pedronauck - I think we should reopen this. The above gets rid of the “Codemirror not defined” error, but the hightlight does not work. Let me explain what I tested.
From the Codemirror docs, it appears that hightlighting for
scss
orless
comes directly from the CSS mode in the form of mime types, which aretext/x-scss
andtext/x-less
. Therefore, you do not need to import another package. Importing the CSS mode is good enough.You would think you could also pass
mode: 'scss'
but for some reason you cannot. The highlighting does not work.It does work if you pass
mode: 'text/x-scss'
.Weird, right?
Since you already import the CSS package here: https://github.com/pedronauck/docz/blob/master/packages/docz-theme-default/src/components/ui/Editor/index.tsx#L21
I propose that to at least support
scss
andless
in addition tocss
, we make an immediate change like this:Link to code
Down the road, more changes will be necessary to allow syntax highlighting for other languages such as “Ruby” for instance.
It does not seem that adding a package like
https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.0/mode/ruby/ruby.min.js
will be good enough to support different syntax highlighting for different languages.What do you think?
Yeah can we reopen this?