With WYSIWYG module and the CKEDITOR CKEditor 3.5.2, everything installed just fine, aside from this problem, which I have solved http://drupal.org/node/1103448 however in moving over stuff from our plone site to drupal some of the pages have astronomical formula, with greek symbols (Delta...etc) when these were inserted into a page, either they disappeared and nothing was saved or the message this web site has had a problem would come up.

It seems that when saving the page, the editor would change the symbol Δ in the source code to a Delta symbol Δ. so that when it was saved again it barf up an error. I though this might be a filter problem but after playing with and turning of the filters nothing seemed to solve the problem.

There was some information about this problem, but it was old and referred more to the plain CKeditor module (in which this problem does not appear), I tried changes in the library by changing config.js, such as trying:

CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#111';
config.htmlEncodeOutput = false;
config.entities=false;
};

However this and a few other proposed solutions did not work. I have given up and am using the CKeditor module, which works fine, however I would really like to solve this so that I can use the WYSIWYG module with a few other interesting modules that are coming out.

David

Comments

sun’s picture

The reason we do this is that content in non-English or non-Latin languages would otherwise contain plenty of converted HTML entities and potentially not a single plain character anymore. I.e., someone writing a post in Greek would see total garbage when looking at the HTML source code.

It looks like you tried to override the configuration via JS - however, did you already try to override it via the settings alter hook?

twod’s picture

Category: bug » support

The reason modifying config.js didn't work is because it's not being loaded. Wysiwyg generates all settings for the editor and passes them directly to the new editor instance when it's created.

As Sun said, you can override the generated settings, or add new ones, by implementing hook_wysiwyg_editor_settings_alter() in a custom module. (Example in wysiwyg.api.php and the issue queue.)

It should look something like this: (I can't guarantee these are the values you're looking for, just translating the snippet you posted to PHP for use in the hook.)

function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
 if ($context['profile']->editor == 'ckeditor') {
   $settings['htmlEncodeOutput'] = FALSE;
   $settings['entities'] = FALSE;
 }
}

I don't think this is a bug but more of a consequence of the settings Drupal/Wysiwyg use as defaults.

dwalker51’s picture

I had already tried that...thanks... with

function ckeditor_config_wysiwyg_editor_settings_alter(&$settings, &$context) {
if($context['profile']->editor == 'ckeditor') {
$settings['htmlEncodeOutput'] = FALSE;
$settings['entities'] = FALSE;
$settings['uiColor'] = '#ff0099';
}
}

The editor comes up with a lovely fuchsia, so something is being read..but it still shows a Δ in the source code. the exact error message is "The website encountered an unexpected error. Please try again later." and it doesn't save the content.

This is what I am a pasting :

Exposure time: 10 min
Filter: V
Airmass ADC on: 2.2
Airmass ADC off: 1.8From forty stars relatively close and spaced evenly around the center, the average fwhm:
ADC on = 5.23 ± 0.05 → 1.41" ± 0.01" (error in the mean)
ADC off = 5.04 ± 0.06 → 1.36" ± 0.02" (error in the mean)
Δ airmass: +0.4
Δ fwhm: +0.19 (0.05") (Δ = ADCon - ADCoff)
twod’s picture

Please use <code></code> tags when posting snippets and special characters, makes it easer to determine if you really mean the literal Δ or the entity &Delta;.
Am I right in that you want to store Δ as a single character, but get &Delta; instead?
Setting the "entites", "entities_latin", "entities_greek" options to FALSE should stop the editor from inserting new glyphs as &something; entities, and prevent it from converting existing glyphs to entites as well. Wysiwyg sets the latter two to FALSE by default, and you set the first one to FALSE as well, so it should work. I made some quick tests with Wysiwyg's default settings and it showed up as Δ, at least when copy/pasting from here. Inserting &Delta; into the source also got converted to Δ.

Are you using a math filter for rendering this content? The error suggests something is going wrong on the server after the content has been submitted. Wysiwyg doesn't run any code a that point, it just detaches the editor before the form is submitted (same thing that happens if you click "Disable rich-text") to make the contents sync back to the original textarea.
Do you see any more detailed errors in any Drupal/PHP logs?

Btw, if you're using the Teaser Break plugin, please disable it and test without it, just to rule it out.

dwalker51’s picture

I want to save Δ as mentioned.

I copy from original page...and paste it into the editor
If I then view the source

This is what appears, the editor doesn't convert the Δ to Δ

<p>Exposure time: 10 min<br>
	Filter: V<br>
	Airmass ADC on: 2.2<br>
	Airmass ADC off: 1.8From forty stars relatively close and spaced evenly around the center, the average fwhm:<br>
	ADC on = 5.23 ± 0.05 → 1.41" ± 0.01" (error in the mean)<br>
	ADC off = 5.04 ± 0.06 → 1.36" ± 0.02" (error in the mean)<br>
	Δ airmass: +0.4<br>
	Δ fwhm: +0.19 (0.05") (Δ = ADCon - ADCoff)</p>

when saving, the error comes up and it doesn't save the content.

If I try an experiment and open the editor , click source and type in &Delta; and then unclick the source button i get a
Δ

good!!

If I click source again I see:

<p>Δ</p>
<div id="myEventWatcherDiv" style="display:none;">&nbsp;</div>

And once again on saving, the error comes up.

In response to your other questions: No I am not using a math filter or the Teaser Break plugin.

Thanks again!

rainbowarray’s picture

This is a completely unacceptable situation. HTML special characters need to be encoded, and every time I try to change quotation marks using either entities or their unicode equivalents, these are being turned back to normal text. This has the possibility of causing browser errors. I shouldn't have to create a new module to rectify this situation. At present, I'm going to look for a different module.

twod’s picture

Thanks for the clarification, I first thought you wanted the opposite result.

I don't understand what browser errors you're talking about, all browsers I'm aware of handle Unicode/UTF-8 fine, which is what Drupal outputs. W3's validator does not complain when not using &Delta; either. This is why Wysiwyg changes CKEditor's entities_greek setting to false. See http://htmlpurifier.org/docs/enduser-utf8.html#whyutf8 for a quick explanation.

I've not encountered any serverside errors when submitting non-entity Delta characters either, do any of the logs (Drupal, server etc) show any more details about the errors? You might need to change which PHP errors are displayed on the screen, since what you saw is a generic error displayed when the page could not be generated due to a fatal error. Sounds a lot like a module got can't handle Unicode/UTF-8 content. That might cause subtle errors elsewhere so I'd investigate that further by either testing with a fresh installation and adding modules until the errors happen, or by disabling modules on the site until the error goes away, to find out where things go wrong.

Anyway, I have confirmed that you can override Wysiwyg's settings for CKEditor like this

function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
 if ($context['profile']->editor == 'ckeditor') {
   $settings['entities_greek'] = TRUE;
   $settings['entities_additional'] = 'quot';
 }
}

and it will output the Delta character as &Delta; and change the Quote character as well. It's very common to have a customization module for each site and this snippet could go there. In the future we'll create a GUI to change settings like this, at which point the snippet won't be needed anymore.

I have also confirmed that the Teaser Break plugin will convert &Delta; back to Δ, so it needs to stay disabled until we can fix that.

sun’s picture

Status: Active » Closed (cannot reproduce)

This has the possibility of causing browser errors.

As @TwoD already explained, this statement is invalid.

I don't think there's anything we can reasonably do here, as we're already doing the best that can be done to make HTML characters/entities conversion not break on multilingual or in general non-English sites. Also, I don't want to see a setting for this in the future.