FCKeditor after capital letters and colons
Posted January 7th, 2009 in FCKEditor and PHP
I use FCKEditor on my content driven websites to write the content. In version 2.6.3 I have found that the editor inserts characters after capital letters and the colon character, and I don't want this behaviour. This post shows a server-sided solution to the problem using PHP.
The issue doesn't appear to occur after all capital letters but always appears to do it after capital I and after colons. It doesn't appear to occur in FCKEditor 2.6.2 (which I have installed on this blog - I have 2.6.3 on my newer blogs and haven't yet upgraded this one).
I couldn't find anything in the configuration options which would switch this behaviour off. The FillEmptyBlocks configuration option doesn't affect this particular issue, and isn't really one you'd want to switch off anyway.
Here's an example of some text that I entered into the editor:
On this line I will be followed by a non-breaking space. On this line the word GUI will be followed by a non-breaking space. This is a list: this is item one; this is item two.
You would expect the source to look like this:
<p>On this line I will be followed by a non-breaking space.</p> <p>On this line the word GUI will be followed by a non-breaking space.</p> <p>This is a list: this is item one; this is item two.</p>
But it actually looks like this (I've marked the in red):
<p>On this line I will be followed by a non-breaking space.</p> <p>On this line the word GUI will be followed by a non-breaking space.</p> <p>This is a list: this is item one; this is item two.</p>
Note that when the paragraph starts with the letter I it doesn't always put a non-breaking space after it.
As I mentioned above I couldn't find a configuration option in the Javascript configuration which would solve this issue, so instead resorted to a PHP regular expression on the server-side to fix it. I don't want to replace all with a space - just those after capital letters and colons, so we need to use a regular expression instead of a straight str_replace.
If the html is stored in the $html variable in the code below, the regexp would look like this:
$html = preg_replace('/([A-Z:]) /', '\\1 ', $html);
The ([A-Z:]) bit matches capital letters A to Z and colons which are followed by
The matches are then replaced with the [A-Z:] part followed by a regular space. The \\1 matches the stuff in the brackets in the first parameter.
Related posts:
- Insert HTML into FCKEditor (Friday, February 13th 2009)
- Remove "Browse" button and "Upload" tab in FCKEditor Link dialog (Tuesday, January 20th 2009)
- Always make FCKEditor paste as plain text (Tuesday, November 11th 2008)
- Using the FCKEditor HTML Editor with PHP (Wednesday, August 20th 2008)
- FCKEditor: Using a custom configuration file (Saturday, August 9th 2008)

Comments
blog comments powered by Disqus