E107: not able to use <pre><code> syntax in tinymce area

Created on 2 Jan 2020  路  11Comments  路  Source: e107inc/e107

Bug Description

For highlight.js I need to use code <pre><code> </pre></code> in tinymce area
Now it's changed to
<pre>&lt;code&gt;pre2&lt;/code&gt;</pre>
by e107.
I already know that
<pre> and <code>
tags have exceptions and they should not be converted to HTML entities, but if you combine them, this happens

How to Reproduce

Steps to reproduce the behavior:

  1. Go to news with tinymce plugin activated
  2. Either use source button to insert needed code
  3. Or insert code, than use button for inserting<code> tags, and then button for <pre> tags
  4. Check source code before saving that code is inserted correctly
  5. After saving check source code again or saved value in database

Expected Behavior

tag shouldn't be converted to HTML entities

e107 Version

latest github 2.3

PHP Version

PHP Version 7.2.16
bug

Most helpful comment

btw.

For highlight.js I need to use code <pre><code> </pre></code> in tinymce area

I think you mean:

<pre><code> </code></pre>

TinyMce Source:

[html]<p>To create a simple test script, create a new file called <code style="unicode-bidi: embed; direction: ltr;">test.php</code> in your root folder with the following php:</p>
<pre class="prettyprint linenums">require_once("class2.php");
require_once(HEADERF);
echo "Hello World";
require_once(FOOTERF);
</pre>
<p>Then point your browser to <code style="unicode-bidi: embed; direction: ltr;">www.yoursite.com/test.php</code></p>[/html]

Rendered Result:

See: https://e107.org/developer-manual/getting-started/hello-world

All 11 comments

Tested with simplemde plugin by lonalore that have already this script supported. Before 3 years ago it worked. Now the same result: <pre>&lt;code&gt;test&lt;/code&gt;</pre>

@Moc change label to question, this is probably the intention. I don't need this anymore.

@Moc I believe this is the parser error we saw on e107.org. It should normally be fixed now.

It is not. I tried it after that fix. You don't see it normally because HTML entities are displayed correctly, but you can't use it for js <pre><code> test doesn't work.
But as I said, I don't need this anymore.

TinyMce also seems to be adding <br> instead of \n inside the <pre> tag.

btw.

For highlight.js I need to use code <pre><code> </pre></code> in tinymce area

I think you mean:

<pre><code> </code></pre>

TinyMce Source:

[html]<p>To create a simple test script, create a new file called <code style="unicode-bidi: embed; direction: ltr;">test.php</code> in your root folder with the following php:</p>
<pre class="prettyprint linenums">require_once("class2.php");
require_once(HEADERF);
echo "Hello World";
require_once(FOOTERF);
</pre>
<p>Then point your browser to <code style="unicode-bidi: embed; direction: ltr;">www.yoursite.com/test.php</code></p>[/html]

Rendered Result:

See: https://e107.org/developer-manual/getting-started/hello-world

@CaMer0n
try to use

 /* {THEME_PREF: code=header_width&default=container} */
  /* way how to use theme prefs as shortcodes in HTML layout */

Result:
image

<pre>&lt;span&gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;&lt;span&gt;/*&nbsp;{THEME_PREF:&nbsp;code=header_width&amp;default=container}&nbsp;*/&lt;/span&gt;</pre>
<pre>&lt;span&gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;&lt;span&gt;/*&nbsp;way&nbsp;how&nbsp;to&nbsp;use&nbsp;theme&nbsp;prefs&nbsp;as&nbsp;shortcodes&nbsp;in&nbsp;HTML&nbsp;layout&nbsp;*/&lt;/span&gt;</pre>

@Jimmi08 I tried what you suggested:

image

TinyMce Source (before saving and after saving/re-editing):
[html]<pre class="line-numbers language-javascript">/* {THEME_PREF: code=header_width&amp;default=container} */ /* way how to use theme prefs as shortcodes in HTML layout */</pre>[/html]
I'm not seeing an issue. Can you provide more details?

It was adding spans after inserting text, before saving itself. I had to switch to source code, insert that text there, switch back, and then use preformatted code button.

Now I can't reproduce it. I don't understand. Closing.

@Jimmi08 Maybe you copy/pasted from elsewhere? (so it pasted additional tags)

@Jimmi08 Maybe you copy/pasted from elsewhere? (so it pasted additional tags)

Visual Code editor.
I tried PSPAD before (comment above) because I use it more, but after your comment, it hit me that I was cleaning code and then I used VC.

Was this page helpful?
0 / 5 - 0 ratings