Closed ya332 closed 2 years ago
@ya332 Thanks for the question.
We haven't tried highlighting Python, but I can try to help. Could you please share the documentation where you found the solution to write <pre><code class="hljs python"> ... </code></pre>
?
Hello @klyburke, I found it here https://github.com/highlightjs/highlight.js/issues/1224.
I also tried highlightAll
and highlightAuto
from https://highlightjs.readthedocs.io/en/latest/api.html#core-api, but they don't highlight for some reason.
@ya332 Thanks for sharing.
From what I read, highlight.js supports python in its core library, so you do not need to pass any tags. See the "Supported Languages" section here: https://highlightjs.org/usage/
I tested your code snippet in the demo book, and I see proper highlighting when I wrap the code with triple backticks (``) instead of
`
When I write with triple backticks like this:
The code is highlighted:
When I write with <pre><code>
like this:
The code is not highlighted:
So try using triple backticks and let me know if that works for you.
Note that I was running the main builderbook/builderbook
app to test.
Thanks @klyburke. this fixed my issue. Closing.
I know that the following snippet highlights markdown in our book:
However, when I write a markdown snippet with Python code in it, it doesn't get highlighted:
Below is the markdown that I am trying to highlight. I checked
highlight.js
doc and it told me to pass