I'm testing TinyMCE as an option for those of my users who are intimidated by HTML. So far it's working well, except for one thing: the HTML generated by TinyMCE is all on one line. Now, this has no effect on what the site looks like, but it does have an effect on the site admin (me) who might want to edit the HTML after the user has submitted it. E.g., TinyMCE makes this:
<h3>My favorite foods</h3><ul><li>tomatoes</li><li>chocolate</li><li>strawberries</li></ul>
I want it to make this:
<h3>My favorite foods</h3>
<ul>
<li>tomatoes</li>
<li>chocolate</li>
<li>strawberries</li>
</ul>
I tried the HTML Tidy module; however this doesn't quite do what I'm looking for--while it provides a *filter* that is applied when the node content is served, it doesn't actually do anything to the user's original input. What I'm looking for is something I can use to automatically make the source of the node legible for advanced users.
(Note: this is not a Filtered HTML issue as I've seen in many other posts. I don't want or care about <p>
tags being inserted, I just want the \n character added in the appropriate places to the actual submission. HTML Tidy does this when the node is accessed (along with indentation), but does not do anything for the actual source I'm editing).
Anyone have any suggestions as to how I could accomplish this? Short of writing my own parser to stick in those line breaks.
Comments
or configure TinyMCE?
Digging through the TinyMCE docs, I found the
remove_linebreaks
config option:http://tinymce.moxiecode.com/tinymce/docs/option_remove_linebreaks.html
Anyone have any ideas as to how I might go about getting Drupal to set this config option for TinyMCE? I have no idea whether it will do the trick, but it seems worth a shot.
remove_linebreaks is not a complete solution
Well, adding
remove_linebreaks
as a configuration option intinymce.module
helps halfway, in that it does not eat the linebreaks from existing HTML documents. However, new nodes created with TinyMCE still do not have any line breaks in the source (nor does content added to existing nodes).Back to the drawing board. Any suggestions as to how I can control line breaks in the TinyMCE output? Ideally, a line break would be added to the TinyMCE-generated HTML each time the user presses enter in the TinyMCE editor box. A less perfect option that would still get the job done would be some sort of formatting cleanup utility (non-filter) that would automatically add linebreaks in good places (like HTML Tidy does), at least after the closing tags of block elements and so forth.
Solution
I found the solution on the TinyMCE forums:
http://tinymce.moxiecode.com/punbb/viewtopic.php?id=2878
To implement these settings, I added the following two snippets to
tinymce.module
In
tinymce_config()
which begins on line 480:In
tinymce_profile_form()
(around line 625):My feature request:
http://drupal.org/node/80851
Cheers!
I've been looking for that fix for ages. Can't thank you enough.
Same here, thanks!
Same here, thanks!
Awesome
Only place i found help on this!
works perfectly taking out/removing the line breaks
dan
Thank You Very Much!!!
For that, you deserve the Nobel Prize.
I just spent a day and a half trying to figure out what was wrong and your solution took me one minute!
Thank you so very much!
Please note that the feature
Please note that the feature request (and patch) for this is over at http://drupal.org/node/80851
TinyMCE line break solution
Thank you!
I hope that tinyMCE module gets updated with your solution!!!
Not working for Drupal 6.5 and TinyMCE 6.x-1.1-dev
Hi all,
could somebody give me a hint why this is not working with Drupal 6.5 and TinyMCE 6.x-1.1-dev?
I would like to get this working asap as I spent so much time to find a solution ... :(
Thanks in advance
SirBerberitz
PS: in my tinymce.module there is no tinymce_profile_form() (around line 625) ???
Found a solution
It was my fault, I found the solution here
Thanks to all!
SirBerberitz