HTMLarea editor strips spaces and line breaks

HTMLarea editor strips spaces and line breaks

by Neal Holtz -
Number of replies: 6
Moodle version: 1.7.1
htmlarea.php version: 1.9.2.1

I'm a bit surprised that I didn't find any other direct
references to this problem, but the HTML editor
collapses all multiple spaces to a single space in text.
In fact, if you edit a document and save it, the first
time you lose the spaces, if you then re-edit it, you lose the line breaks as well.

This happens inside preformatted text, so it kind
of defeats the purpose sad There does seem to
be some code in HTMLArea.indent that tries to prevent this, I guess, but it doesn't seem to work.

For the time being, in htmlarea.php, line 2384, I have
changed:

return HTMLArea.indent(html);

to

return html;

and that seems to serve my purpose.

An earlier version of moodle (1.6.3) did not have this
problem.

Because I expected this to be a well-known problem, I
haven't yet filed a bug report -- I'll look a little harder
to see if I can find it.

cheers
neal
Average of ratings: Useful (1)
In reply to Neal Holtz

Re: HTMLarea editor strips spaces and line breaks

by Steve Garcia -
Are you talking specifically about text inside <pre> tags?

I'm running into this as well. Pages that worked fine under all previous versions of Moodle now break after the first time you edit them.

It seems that the HTMLArea that came with Moodle 1.7.x has decided to get a lot more "helpful". It can be a real pain to deal with.

I've applied your fix. We'll see if maybe it derails some of the reformatting that HTMLArea now does.
In reply to Steve Garcia

Re: HTMLarea editor strips spaces and line breaks

by Neal Holtz -
Yes, that is correct, inside <pre> tags.
Though I normally get those tags in there using
the "preformat" option on the pulldown menu.

If I recall correctly, hat behaviour may occur outside of those tags as well, but it doesn't matter so much there.

I did a diff of htmlarea.php from 1.7.x to 1.6.x and there were a lot of changes, and I think my change disables many of them.
In reply to Neal Holtz

Re: HTMLarea editor strips spaces and line breaks

by Steve Garcia -
Oh, ok. I've never seen a pulldown menu that offered that, but then, I've never looked either.

I have occasionally added <PRE> tags in, but only in source mode. Not too often, though. My problem has been pre-existing pages that have worked flawlessly through 4 major versions of Moodle, only to break in 1.7.
In reply to Steve Garcia

Re: HTMLarea editor strips spaces and line breaks

by tony chesney -

It also causes problems with code referencing .swf files.  This, at least, in the context of the content part of a Lesson Question. 

Latterly, for us, also in Lesson Questions, it has started behaving badly with code which uses absolute positioning of divs.  Behaviour is inconsistent:  anything from joining the div tag into preceding tags, stripping all the code between the div tags, turning the code between the div tags into nonsense (tags like <//option> appear). 

On the one hand, it's understandable that a wysiwyg editor could have problems with code using absolute positioning.  On the other hand, it seemed to handle it OK for a while and kept away from code entered in html source view. 

In reply to tony chesney

Re: HTMLarea editor strips spaces and line breaks

by tony chesney -

In this case, I can get away with  disabling the editor from my user profile to get round the absolute positioning / htmlarea problems. 

This wouldn't work if other people needed to edit the page though. 

In reply to Neal Holtz

Re: HTMLarea editor strips spaces and line breaks

by Paul Craven -
This has long been a source of frustration to me. It makes Moodle very irritating for software programming courses. I have to post PDFs of all my class notes to get the formatting right.