3

I'm using SyntaxHighlighter Evolved to highlight code examples. E.g.

[csharp]
string s = "text";
List<int> numbers = new List<int>();
[/csharp]

When I first save it, it's ok, but when editing wordpress changes the text to

[csharp]
string s = &quot;text&quot;;
List&lt;int&gt; numbers = new List&lt;int&gt;();
[/csharp]   

After second edit it becomes

[csharp]
string s = &amp;quot;text&amp;quot;;
List&amp;lt;int&amp;gt; numbers = new List&amp;lt;int&amp;gt;();
[/csharp]   

How do I disable escaping? I want the content to be exactly what I type.

  • Fast forward seven years, SyntaxHighlighter Evolved is messing with my square brackets both in preview and published page. None of the answers bellow helped. – Viktor Brešan Apr 24 '18 at 18:38
  • And plugin's homepage gives '500 Internal Server Error'. – Viktor Brešan Apr 24 '18 at 18:44
7

I just installed SyntaxHighlighter Evolved, and while testing on an existing post I was dismayed to find that all the quotes " had been converted to &quot; (the single quotes were fine). I was using the HTML editor.

In case you are also in this position, I found that it's just the post preview that is escaped - when you Publish it appears fine.

| improve this answer | |
  • I'm not 100%, but I think after you publish, the preview then subsequently works. – cellepo Oct 16 '15 at 19:55
  • not works for me. syntaxhighlighter + wp markdown – Daniel Hári Jul 26 '16 at 20:37
  • Did solve the problem for me, using SyntaxHighlighter Evolved and markdown from the JetPack plugin. – Guy Aug 23 '17 at 19:36
3

The visual editor will automatically escape HTML tags (the <> brackets in particular) to prevent code you intend to display from being interpreted by the browser as markup. The easiest way to make sure the content is exactly what you type is to use the HTML editor rather than the Visual editor.

I use a code highlighting plug-in called Code Colorer, and I input all of my "highlighted" code directly in the HTML editor just to make sure it appears exactly as I typed it.

| improve this answer | |
  • Using the HTML editor will also allow you to preserve any indenting you have in your code snippets. The visual editor strips out additional tabs and extra spaces ... the HTML editor does not. – EAMann Sep 5 '10 at 14:38
0

The author of SyntaxHighlighter Evolved suggests disabling all other plugins, then enabling them in series, in following solution: http://wordpress.org/support/topic/plugin-syntaxhighlighter-evolved-html-tags-gets-added-to-my-code

However, I found that this solution did not work to prevent html tags being added to the preview. However, as @Lessan Vaezi notes html tags appear only in the preview but not the published post.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.