1

This seems very hard to do.
I'm pasting html code with <pre> into tinymce editor.
All the whitespaces are gone inside the <pre>

e.g. I'm trying to copy StackOverflow's <pre><code>block as in

def foo():
  help me

It seems, tinymce trims whitespaces in <pre><code><span> and newlines are removed

How can I preserve it?
I'm using 3.5.3 btw

Thomas Maierhofer
  • 2,665
  • 18
  • 33
eugene
  • 39,839
  • 68
  • 255
  • 489

1 Answers1

0

First of all you should set the entity encoding setting to raw

tinymce.init({
    ...    
    entity_encoding: "raw",
    ...ยด

But TinyMCE adds <br /> elements on line breaks if you edit your text. Here is a setup for syntay highlighting and preformatted text in NopCommerce, it is almost the same in WordPress or whatever.

TinyMCE Preformatted Text and Syntax Highlighting

Thomas Maierhofer
  • 2,665
  • 18
  • 33