Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This issue is similar to http://drupal.org/node/775076, but has nothing to do with Teaser Breaks.
The issue here is that, after adding the line
config.protectedSource.push( /<tex[\s\S]*?\/tex>/g );
to /libraries/ckeditor/config.js
all content enclosed within the <tex> tags (I'm using the Drutex module) are protected from html encoding during preview, but not after clicking "save". I need to prevent the amersand character, which means something special in LaTex, from being html encoded. This problem is a real mystery to me now, and I'm not sure even where to look for a solution. Any ideas?
Comment | File | Size | Author |
---|---|---|---|
#14 | ckeditor_config.tar_.gz | 682 bytes | BrightBold |
#13 | ckeditor_config.tar_.gz | 889 bytes | BrightBold |
Comments
Comment #1
ShaunDychko CreditAttribution: ShaunDychko commentedTo give other problem solvers some more insight: the issue is that CKEditor html encodes the special characters (like ampersand) when the text field is initially loaded after choosing to edit the node. Here's what happens (with config.js modified as above):
Create a piece of content using the "source" view with CKEditor, and type an ampersand, and click save. In the database you can verify that this will be stored as a single character, which is desired (it isn't html encoded).
Then choose to edit this node. Here's where the problems start. When CKEditor loads the text field it WILL html encode the ampersand, despite the modification to config.js. I've also tried adding:
to /libraries/ckeditor/config.js but these don't solve the problem. There is a problem with the way the editor loads text fields in that it ignores the config.js entries.
Note: I've abandoned this issue in favour of using http://drupal.org/project/fckeditor which, with
in modules/fckeditor/fckeditor.config.js works great.
Comment #2
ShaunDychko CreditAttribution: ShaunDychko commentedComment #3
TwoDIt does not appear to be the entities plugin which does the conversion, removing it has no effect. I'm also unable to stop CKEditor from outputting ampersands as
&
with or without Wysiwyg module.Comment #5
BrightBoldHope I'm not hijacking this issue - my concern is different but the root cause is the same.
I am trying to use WYSIWYG, CKEditor, and Typogrify together. But CKEditor's HTML entities conversion turns the quotation marks into "s and apostrophes into 's, breaking Typogrify's ability to transform them into typographer's quotes.
I also made the
config.entities = false
change to CKEditor's config.js, but it doesn't appear to be reading that file. I assumed this was because of WYSIWYG but TwoD makes it sound like it's a CKEditor problem.At any rate, I was able to temporarily solve the problem by hacking ckeditor.js to include the line
CKEDITOR.config.entities=false;
but of course this is not an ideal solution, since I'll lose my modification if I upgrade CKEditor. It looks like my choices for doing this "the Drupal way" are to write a module to handle it using HOOK_wysiwyg_editor_settings_alter (per this discussion), which I may or may not actually be capable of doing, or wait for WYSIWYG 3.0, which will offer ways to configure individual editors.Have I interpreted what I've read correctly? Are these the options? Any other suggestions?
Comment #6
TwoDYes, those are currently your options. I'm still not sure where all the entity conversions in CKEditor happen. If you're able to influence quotes using that setting I think the entity plugin is doing at least that part. (Not able to look at the code right now.)
A hook implementation to do what you need would look like this:
All you should need is that in MYMODULE.module and a MYMODULE.info file and you're ready to go. Info file specs can be found at Writing .info files (Drupal 6.x)
Comment #7
BrightBoldHaven't tried that yet but it looks straightforward enough - I can do that! Thanks.
Comment #9
borgo CreditAttribution: borgo commentedEdit your profile, under Advanced settings at the bottom set Custom javascript configuration:
config.entities = false;
I needed to stop CK from converting diacritics ščľžď etc to HTML entities. This did it for me.
Comment #10
gstokes CreditAttribution: gstokes commentedThis worked for me thanks this has been wrecking my head.
Comment #11
TwoDIf that worked, you are using ckedtor.module and not wysiwyg.module.
Wysiwyg module will also have a GUI for setting things like this once #313497: Allow configuration of advanced editor settings is done.
Comment #12
John Pitcairn CreditAttribution: John Pitcairn commentedtagging for reference, thanks
Comment #13
BrightBoldFor anyone who's having this problem and doesn't feel comfortable creating a module, here's TwoD's code from #7 in module format. (Note - d.o. renamed it on upload, so if you have trouble uncompressing, just remove the underscore in the extension.)
Works beautifully - now my straight quotes get converted to typographer's quotes by Typogrify. Thanks @TwoD!
The WYSIWYG editor configuration GUI will be a good improvement, but this is great for now!
Comment #14
BrightBoldOops. Just learned the attachment above was empty. Try this one:
Comment #15
TwoDIf you've got the Teaser Break plugin enabled, it will convert HTML entites back to their character form due to a bug. Please try the new xhtml_callback (D7) branch in git and see #510552: Invalid XHTML: missing trailing slashes, absolute urls and uppercase tags for progress.
Comment #16
ShaunDychko CreditAttribution: ShaunDychko commentedShocking triumph!
By creating a module containing the following three lines (replace MYMODULE with your own module name), CKEditor keeps it's hands off LaTeX code, and the code is even displayed in the WYSIWYG view (this was a problem when using the "ProtectedSource" solution before http://drupal.org/node/732162). The LaTeX code is editable only when "Disable Rich Text" is selected.
The following is rendered by Drutex as a proper LaTeX table:
Tested with:
CKEditor 3.6.1.7072
WYSIWYG 6.x-2.4
This still isn't entirely user friendly for the website editors since they must
<tex contenteditable="false"> ...</tex>
around their LaTeX code, and not forget the contenteditable="false" attribute.Can anyone improve on this?
Comment #17
jeff.hartman CreditAttribution: jeff.hartman commentedI've loaded this module (per BrightBold in #13) and have also tried via function in an existing custom module, but can't seem to get the function loading.
I guess it's not clear as to where I should see it loading. Do these overrides happen on every load of form fields that use the CKEditor or does this load when you configure your WYSIWYG profiles?
I've testing by simply putting a
print_r($context)
andprint_r($settings)
within the function itself and nothing is outputted to the page.Thoughts?
I'm using CKEditor 3.4.1.5892 on Drupal 6.2x.
UPDATE: Got this working now, but the difference is that I cannot pass $settings and $context by reference to the function. I see watchdog entries if I do.
Comment #18
DuaelFr#16 worked for me (but my use case has no relation with tex)
I was looking for a way to disable entities auto conversion because it is not really good with Diff module.
Comment #19
ShaunDychko CreditAttribution: ShaunDychko commentedGlad you found #16 useful. Note that the ampersand in front of the $context variable should be removed (it throws an error in PHP 5.3.x). It should be:
Comment #20
TwoDYes, $context is not intended to be passed by reference (modifying it would confuse the heck out of Drupal/Wysiwyg) so it should not use the ampersand. Some of my earliest hook_wysiwyg_editor_settings_alter() examples included it by mistake and have been copy/pasted around quite a lot. But, I try to fix them as I find them so I just removed it from my previous post. Could you please edit #16 as well, Shaun? Just in case someone copy/pastes it without noticing the ampersand. Thanks.
Comment #21
ShaunDychko CreditAttribution: ShaunDychko commented#16 looks correct now. Cheers.
Comment #22
dlats CreditAttribution: dlats commentedAdded the module, but getting & as &; on the first save, then & on the next edit. What else could be wrong/misset?
Comment #23
dlats CreditAttribution: dlats commentedOops. Some more info. This is part of a url in an anchor. The second & in the above post was fully an html entity not just an &.
Comment #24
dlats CreditAttribution: dlats commentedFound it. I used $settings['forceSimpleAmpersand'] = TRUE; instead and disabled the module called "Pathologic".
Comment #25
MatteNoob CreditAttribution: MatteNoob commentedBeen working on this for hours on end now. I'm trying to use drutex with wysiwyg and ckeditor.
The ampersand is converted to
&
. I have written a little module which loads an additional js-file where I try to set the properties.The .info
The .module
I've added the drupal_set_message to see if it is run, and it is.
The .js
However, when I type something in the CKeditor field and click source the entities are converted to
&
Also if I write some latex and just save the output drutex parses images with
<br>
,&
and other htmlentities. What am I missing, please?Comment #26
ShaunDychko CreditAttribution: ShaunDychko commentedI've been using #19 with the same set-up as you have (Drutex with CKEditor with WYSIWYG), and it works for me.
Comment #27
runeasgar CreditAttribution: runeasgar commentedI can't get this working. Every time I "edit" a node with a WYSIWYG body that contains quote characters, they get converted to HTML entities in the WYSIWYG source, and when I save, it then outputs those entities directly to the browser. This has unfortunately completely crippled a site I was working on and I now have to postpone launch :\
I put this module in place to no avail: