0

I have legacy content that has line breaks as paragraph separator. When trying to deal with them using CKEditor module 7.x-1.16 and CKEditor 4.5.4 library, all line breaks are removed and the text turned into an ugly mass of text.

I tried disabling some filters from the Full HTML input format:

  1. Limit allowed HTML tags

  2. Convert line breaks into HTML

  3. Correct faulty and chopped off HTML

I also tried to use custom formatting options and disabling _Advanced content filter. In any case, I didn't achieve my purpose.

2 Answers 2

1

Wysiwyg Linebreaks

You can choose between two different methods:

  • Force linebreaks: Your content will always preserve whitespace/linebreaks around blocks of text, rather than paragraph
    and break tags.
  • Convert linebreaks: Your legacy content will appear correctly in your WYSIWYG editor, then the content will be saved with the markup added by the editor).
2
  • 1
    There is a big problem in your solution for me, as I regarded, I use CKEditor module (stand alone) not the Wysiwyg module.
    – SaidbakR
    Oct 16, 2015 at 11:23
  • in ck editor only convert br option convert into HTML if you change text editor then you able to solve your problem
    – Adi
    Oct 16, 2015 at 12:15
1

The solution is simply in two points:

  1. Adding the following config to in the advanced option tab of the desired profile: admin/config/content/ckeditor/edit/Full

    config.protectedSource = [/\r|\n/g];

This will keep the source of the content with new lines as it is and forget about its shape in the wysiwyg.

  1. In for the container that holds your content, use the following css rule:

    white-space: pre-line; This will keep lines separated as paragraphs.

checkout those screen shots:

Add the protected source config: enter image description here

Don't worry about it in wysiwyg: enter image description here

Just look at the source: enter image description here

It will look like the following on the frontend:

enter image description here

Don't forget to flush cache specially if you optimized and aggregate js and css, also remove your browser cache or enabling remove cache during using dev tools (chrome)

1
  • 1
    Assalam-o-alaykum. This bug seems to be removed in drupal 7.54. Tested it on long text textarea field which I was having problem when using 7.50. Yet to test with better formats. Hope it has nothing to do with it.
    – Umair
    May 22, 2017 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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