Syntax Highlight and TinyMCE4

1

Whenever I put a JS, PHP or CSS script in tinymce within the <pre> tags, as Syntax Highlight does, it works perfectly, however if I want an HTML script, as tinymce is an HTML editor, it takes my own tag <pre> and throw the HTML out. This way Syntax Highlight can not read and format the script. How do I resolve this?

    
asked by anonymous 29.01.2014 / 14:16

1 answer

1

TinyMCE, like all text editors for fields on a web page, converts tags into special characters so it is displayed on an HTML page.

For example, if you enter the field with the following:

<pre>
     <div>
          Conteúdo da Div
     </div>
</pre>

The result of this field will be:

&lt;pre&gt;
     &lt;div&gt;
          Conteúdo da Div
     &lt;/div&gt;
&lt;/pre&gt;

So, if you want to display with Syntax Highlight, you would have (or by PHP, or JavaScript, or whatever you want) to set the text inside a

 tag, this would be: 

<pre>
     &lt;pre&gt;
          &lt;div&gt;
               Conteúdo da Div
          &lt;/div&gt;
     &lt;/pre&gt;
</pre>
    
29.01.2014 / 19:10