Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
2.1k views
in Q2A Core by
I am using ckeditor. When I edit a question or answer and press the return key it looks to me like I have entered a new para in the visual editor. In fact on inspecting the document source, I do see a new para <p> being insereted with every return and makes me believe that formatting.

But on saving, and vieweing the question description or answer, I see what looked like a new para is now a newline. Breaking the formatting I was assuming before and making it look bad. I need to use shift enter-enter to actually create a new para with ckeditor.
by
Interesting here what i saw is what i got as result. But in my installation WYSWIG editors screw up with new para.

1 Answer

+2 votes
by
edited by
 
Best answer

Nice article. I always remembered a sense of incongruity for this movement, too. I checked it.

I hacked plugin source to just store <BR>/<P> tag which CKEditor input.

qa-plugin/wysiwyg-editor/qa-wysiwyg-editor.php : function read_post()
qa-plugin/ckeditor4/qa-ckeditor4.php : function read_post() <== For my CKEditor4 plugin.

//$htmlformatting=preg_replace('/<\s*\/?\s*(br|p)\s*\/?\s*>/i', '', $html); // remove <p>, <br>, etc... since those are OK in text
$htmlformatting = $html;
<P> tag is just stored by upper hack. However, I cannot understand need of this code enough. Therefore, another problem may occur by upper hack. Gideon will be able to explain meaning of this line enough.
by
Great. This helps. Then I also did some modification to the css to remove margin-top to the p in snow theme.
by
edited by
This line of code also crossed my way and I was wondering what it means.

Now I think the following: If the posted text only contains <p> and <br /> it shall be saved as only-text. If there are other html tags included, it gets saved as HTML. Probably the reason was to save database storage in removing the <p> and <br /> tags.

I don't know if it is a good idea, but I remember some of my users complaining about missing lines etc. but I cannot say if this was correlated to the preg_replace above...

--

The problem with this, however, is that a pasted text which is written in one line, e.g. "<p>Test</p> <p>Test</p>" will become:

"Test Test"

instead of:

"Test
Test"

Which is of course incorrect.
by
I conclude, we should declare this line as a bug.
...