How to escape the angled brackets (“<”, “>”) in prism?

337 Views Asked by At

Writing my WordPress post including dart code in a <pre class="language-dart"><code> block, I found out that, the part in between angle brackets are not showing, I'm using prismjs syntaxhighlighter.

Contact.fromMap(Map<String, dynamic> map) {
id = map[colId];
    name = map[colName];
    mobile = map[colMobile];
  }

It's now showing <String, dynamic>. But with prism script tag this problem can be avoided.

<script type="text/plain" class="language-dart">
..code goes here..
</script>

But wordpress code block prevents code preview in avada theme builder because of script tag.I've seen somewhere wordpress does not allow script tag in code block. Is there a solution?

I have downloaded Prismjs with these settings:https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript+aspnet+bash+csharp+dart+kotlin+python+jsx+sql&plugins=line-highlight+remove-initial-line-feed+unescaped-markup+normalize-whitespace+toolbar+copy-to-clipboard+match-braces.

1

There are 1 best solutions below

0
On

You can't.

You need to use &lt; and &gt; instead of < and >.