code-syntax-block icon indicating copy to clipboard operation
code-syntax-block copied to clipboard

Doesn't highlight in python

Open slimmilkduds opened this issue 7 years ago • 5 comments
trafficstars

The highlighting doesn't work in Python (GB v4.0). Otherwise this looks really sweet!

slimmilkduds avatar Oct 20 '18 19:10 slimmilkduds

Python is my primary use case for the plugin. I can confirm it is working for me on my post here: https://mkaz.blog/code/python-string-format-cookbook/

It would be great if you can try it again with the latest versions of Gutenberg and the plugin, and let me know if it works for you.

After adding a code block, you will need to select the language on the right, and the color does not show in the editor, only after published. See gif below for a quick example:

mkaz avatar Nov 12 '18 19:11 mkaz

Closing, please reopen if the problem still exists.

mkaz avatar Dec 11 '18 13:12 mkaz

Hi @mkaz, I've found the same problem with python, but it works on javascript as see in my gif

out2

Thanks for helping :)

mildronize avatar Nov 10 '19 05:11 mildronize

I've tested a lot about the Prism.js. I think it doesn't this plugin. This plugin just adds the additional class for code and pre (language-python), then when Prism has been loaded, it'll perform all matching class.

This snippet shows that it works! https://jsfiddle.net/mildronize/1wujfkLt/3/

I'll find out another solution to solve this one. (It may be my fault)

Thanks.

mildronize avatar Nov 11 '19 04:11 mildronize

The problem is solved. I need to add the python component of the Prism.js

For javascript es6,

import Prism from 'prismjs';
import 'prismjs/components/prism-python';
Prism.highlightAll(); 

image

Thank you for useful plugin.

mildronize avatar Nov 11 '19 07:11 mildronize