2

I'm working on a project using Django(3) in which I have blog posts and in these blog posts, I need to highlight code chunks in case we are writing a programming article. So, I decided to use PrismJS library.

I have added the required CSS and JS files of the library:

<link rel="stylesheet" href="{% static 'css/prism.css' %}" data-noprefix/>
<link rel="stylesheet" href="{% static 'css/prism-synthwave84.css' %}"/>
<link rel="stylesheet" href="{% static 'css/prism-line-numbers.css' %}"/>

<script type="application/javascript" src="{% static 'js/prism.js' %}"></script>
<script type="application/javascript" src="{% static 'js/prism-line-numbers.js' %}"></script>

Now, inside the admin panel, I have integrated "ckEditor" for writing content. enter image description here

To highlight the code we need to place it inside the <pre><code> tags and add a css class as language-python to highlight python code.

The problem is when we add this class and save the blog posts, this class disappears automatically. Don't know why it behaves like this? Sometimes it remains but if we update the blog posts, it disappears automaticly.

Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150

0 Answers0