3

I've tried every combination of "CLEANUP AND OUTPUT" settings that might conceivably prevent munging my HTML, but nothing works. No matter, what, my HTML gets flattened or in some way rewritten, mainly with whitespace being trimmed off that I want to leave in.

I would suspect CKEditor (version 3.6.4.7575) except that when I tell WYSIWYG to "Apply source formatting", CKEditor doesn't prevent that, so it seems that logically this problem is in the WYSIWYG module. "Apply source formatting" simply causes the HTML to be screwed up differently. Some linebreaks are left in place, but spaces at the beginning of the line are left in place.

How can I prevent this, and still use a WYSIWYG editor?

3

I had just run into this problem of wysiwyg editors reformatting the html source into a minimized blob of contiguous html.

The solution I found was to use TinyMCE editor with WYSIWYG and to add an additional module called wysiwyg-codemagic. With this module, you place the codemagic plugin for TinyMCE in the TinyMCE library's plugins (Follow the instructions in module's Read.Me).

Now, when the author of the node content drops into the html source, as occasionally needed, the source is very readable and presented correctly.

This was an old post, but I thought this new info would help for the others of us that still run into this problem

  • wysiwyg_codemagic is nice. But it also has limits e.g. no support for PRE tags. – Bisonbleu Aug 27 '15 at 14:34
  • Depending on your use case, Wysiwyg Linebreaks may be a viable alternative. – Bisonbleu Aug 27 '15 at 18:03
2

Have you looked at the Text Formats section in the administration pages, such as admin/config/content/formats/filtered_html? Especially note the "convert line breaks into HTML" setting, and the "Limit Allowed HTML Tags" tab, as these settings will affect your HTML output even after the WYSIWYG editor is done with it.

  • Thanks! I'll test this and choose your answer if it solves the problem better than my work-around. – iconoclast Oct 30 '12 at 14:38
  • 3
    I don't know; based on the info in your answer, it looks like your problem is probably the wysiwyg module, not the text formats. Maybe you could add more info to your question about exactly what sort of whitespace trimming is happening. If you look at the node contents in the database, you'll also be able to tell if your problem is caused at save-time or render time. If it looks okay in the DB, fix your text formats. If it's munged in the db, look at your WYSIWYG settings. – greg_1_anderson Oct 30 '12 at 15:48
  • Awesome: very good point. I'd up-vote that comment three times if I could. – iconoclast Oct 30 '12 at 17:21
1

This may not solve all of your problems, but I can recommend the WYSIWYG Filter module. It provides a new filter you can add to your input format(s), giving you more control over the HTML code that the input format should allow.

0

One solution is to make rich text editors NOT the default. This is really a work-around, but it allows me to have some pages use well-formatted and non-mangled HTML without fearing that everytime I edit the page it'll make a round-trip through whatever is munging it (either the editor, or the WYSIWYG module, or the text format settings). As long as I don't open the rich text editor on that node (or panel page) I'm okay.

Another similar work-around is to define a text format (e.g. "Pure HTML") which doesn't allow a rich text editor. Then select that text format for pages where you want to edit the HTML manually.

Neither of these are complete solutions, unfortunately, because for any given node you can either have a rich text editor or complete control over your HTML and its formatting.

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.