4

We are using WYSIWYG with CKEditor on Drupal 7.

When the edit button on a node is clicked, the edit page shows text in a jumbled mess, even if there was careful formatting. The text formats have the "Convert line breaks into HTML" filter enabled, as well as having the <p> and <br> tags allowed. As per a comment, I have taken these tags out of the allowed HTML on the filtered HTML format.

WYSIWYG Linebreaks is enabled as well, but doesn't seem to solve the issue.

If breaks are added in, they seem to stay, even when editing the text again.

My question is: What is causing this formatting to break, upon clicking the edit button?

Example of ruined formatting: On the left is the page view (with correct formatting), and on the right is the edit view (with incorrect formatting)

On the left is what you see when viewing the page before it has been edited (i.e. the page was written by someone else), and on the right is the jumbled mess that is the edit page. On the edit page, all the paragraph or line breaks have been removed.

7
  • What kind of mess? Can you show an example? Oct 14, 2013 at 21:48
  • @KariKääriäinen I added an example showing the viewed page on the left, and the ruined format on the right. It looks slightly small, but I think it gets the point across?
    – Draedalus
    Oct 14, 2013 at 22:01
  • Did you copy the text from any site and paste into your editor? Oct 15, 2013 at 9:43
  • @JayendraKainthola Hmm I can't speak to that as I didn't write this text. But it is probable. Is there a known problem with this?
    – Draedalus
    Oct 16, 2013 at 20:45
  • @Draedalus, Sometime it generate the problem. When we copy content from external site or ms-word into editor, if text contains any html tag, then editor convert these tag into html entity . Click on 'Disable rich text' and check the source of text. May be that would be helpful for you. Oct 17, 2013 at 5:09

1 Answer 1

5

You are using using filtered html (Text Format). [As per your screenshot above]

Filtered HTML only all the following HTML tags

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

You need to change text format to FULL HTML if you wish to retain all HTML formatting

As a best practice Full HTML use should be limited

7
  • You can set what tags are allowed, correct? I you look in the image on the right, you can see under Allowed HTML tags, that <p> and <br> are allowed tags. Are those not being recognized by that text format? Also, why aren't the lines and paragraph breaks staying in the text? That is the point of the question.
    – Draedalus
    Oct 16, 2013 at 20:43
  • 2
    Filtered HTML text format exists so you don't have to use wysiwyg editor or <p> and <br> tags. Don't mix these. Out of the box, Filtered HTML doesn't allow <p> and <br> for this reason. Here is an overview about how text formats work: pingv.com/blog/text-formats-101-how-drupal-filters-work Oct 17, 2013 at 8:21
  • @KariKääriäinen Thanks, that makes sense. Also isn't there some security risk in allowing anyone to use full HTML?
    – Draedalus
    Oct 18, 2013 at 18:31
  • Absolutely. If you're allowing untrusted users to edit nodes, the text format, wysiwyg or not, must have the "Limit allowed HTML tags" filter. Oct 18, 2013 at 19:08
  • 2
    The answer is technically correct. How to setup text formats, filters, and wysiwyg editors keeping security in mind is a complicated matter. Oct 18, 2013 at 19:58

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