Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript syntax highlighting in PyCharm Professional

I'm using sekizai in the Professional version of PyCharm to control where my JavaScript code is rendered to in the page.

In my django template code, this means that my JavaScript is not enclosed in the usual <script> tags and therefore does not have syntax highlighting, e.g. Normally I would have...

<script type="text/javascript">
    alert("Syntax highlighting works");
</script>

Instead I have something like:

{% addtoblock "js" %}
    alert("No syntax highlighting!");
{% endaddtoblock %}

Is there a quick fix for this? The <script> tags exist once in my base template and I'm trying to avoid moving the tags inside {% addtoblock %}:

<script type="text/javascript">
    {% render_block "js" %}
</script>
like image 240
isedwards Avatar asked Nov 21 '25 16:11

isedwards


1 Answers

I contacted PyCharm support in Oct '17.

Their lead Django integration developer replied that currently this case is not supported...

But, I'm sure this would be possible if you knew how to add a new syntax highlighting rules. It should be possible to adapt the answer here: https://stackoverflow.com/a/41044381/1624894

like image 70
isedwards Avatar answered Nov 24 '25 21:11

isedwards



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!