TinyMCE HTML Encode Specific Char

so having an issue posting a word press page that contains backslash. I need to have the backslash to show a document path. This seems to be a common issue for wordpress with a simple solution. Use the HTML encoded alt (& # 9 2 ;). OK this works but you have to enter this in the HTML view, fine for me but not other users.

What i am attempting to do is alter TinyMCE to encode this the same way it does for an ampersand. Digging through the source code I found this.

Read More
o={'"':"&quot;","'":"'","<":"&lt;",">":"&gt;","&":"&amp;","`":"`"}
a={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&apos;":"'"}

ok well that looks like something to work with, so i changed it adding the the backslash and the encoded text for the backslash

o={'"':"&quot;","'":"'","<":"&lt;",">":"&gt;","&":"&amp;", "":"\","`":"`"}
a={"&lt;":"<","&gt;":">","&amp;":"&", "\":"","&quot;":'"',"&apos;":"'"}

figuring this would configure Tiny to encode and decode the value but no luck……..

What did I miss?

I made this change to all the .js files i could find with that config and then ended up having to also change the .js file that is in the .gz. Finally I am seeing this in the source on the rendered page but still no effect on how the backslash is handled.

This seems like it should be fairly trivial but now I am stuck.

Thanks in advance for any help

Related posts

Leave a Reply

2 comments

  1. so after a lot of trial and error this is what i got working. with the help of some other answers here. some of the other events do not work for this as the change will get stepped and you will still end up with the raw value of

    tinyMCE.init({
        setup: function(ed) 
        {
            ed.onGetContent.add(function(ed, o) {
                // Replaces all a characters with b characters
                o.content = o.content.replace(/\/g, "\");
            });
        }
    });