lqez / django-summernote

Simply integrate Summernote editor with Django project.
MIT License
1.05k stars 226 forks source link

How to add <code> tag to the code style in django-summernote? #478

Closed satvikjadhav closed 2 years ago

satvikjadhav commented 2 years ago

Hi there. I have a bit of issue.

When I am using the code style in the editor. I get the following syntax: <pre class=""><br></pre>

However, I need it to look something like this: <pre class=""><code><br></code></pre> I need the <code> tags in order for highlight.js to work.

Is there a way to edit this in django-summernote files? If so, please let me know where I can find it. Otherwise any other way to get <code> tags after the <pre> tags would be much appreciated.

Thank you.

satvikjadhav commented 2 years ago

I was able to over come this using a simple jQuery script.

In case anyone comes across same/similar issue I was facing, here is what I did. Since all I wanted was to have the the <code> tag inside <pre> tag, I used the following jQuery script:

<script>//<![CDATA[
        $("pre").wrapInner(document.createElement("code"));
        //]]></script>

I used this to add the <code> tag inside <pre> tags.

Hopefully this helps anyone going ahead.