Title: Code escaping
Last modified: July 13, 2020

---

# Code escaping

 *  Resolved [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/)
 * I have an issue in the backend (using Prism.js).
 * Code escaping does not work. Using classic editor and set Content Code escaping
   to Admin area only.
 * When I paste the code it gets inserted into the post as it is.
    Consequently 
   you see nothing when you switch to Visaual. When you switch to Text you see the
   original, not escaped code.

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/#post-13117766)
 * Code escaping only converts certain characters (like angle brackets) into their
   HTML equivalents. No highlighting is possible using the Classic Editor.
 * That in mind, I would be glad to take a look at your code snippet and test on
   default WordPress. Note, if it is a large snippet, maybe share it via any code
   sharing service (e.g., [this one](https://www.codepile.net/pile/woAb06KR)). Thank
   you.
 *  Thread Starter [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/#post-13117806)
 * This code
    `<div ad-type="leadboard" ad-data="picture"></div>`
 * should be converted into this code:
 * `& lt;div ad-type="leadboard" ad-data="picture"& gt;& lt;/div& gt;`
 * but it is not – it remains unescaped.
 * It also seems code blocks do not work here on the forum – HTML entities in the
   code block are converted into characters.
    So I added a space after & character
   to show the actual code
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/#post-13118003)
 * Thanks I will take a closer look and try to resolve any issue.
 * Not sure about the code blocks here on the forum, not something I have any control
   over. Maybe bring it up to the forum mods?
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/#post-13223929)
 * Just to follow up with this, here is what I think is happening. When you escape
   code in the Admin Area (via the plugin settings), and paste your code example
   into the Plain Text Editor, the code is inside of a textarea, so it is escaped
   in the source code, in order to display correctly. For example, if you add your
   code and then view the page source, you will find that is escaped completely:
 * Updated to add: it doesn’t seem possible to add unescaped characters via the 
   forum. The following example should have all angle brackets replaced with HTML
   entities.`</update>`
 * `<textarea class="wp-editor-area" style="height: 367px" autocomplete="off" cols
   ="40" name="content" id="content"><pre><code><div ad-type="leadboard" ad-data
   ="picture"></div></code></pre></textarea>`
 * So then when you switch to Visual Editor, the escaped code does not change, it
   remains escaped (which again can be verified by examining the source code). The
   reason this happens is that, by default, the Visual Editor does not display any
   markup, only text, displayed visually. So your example:
 * `<div ad-type="leadboard" ad-data="picture"></div>`
 * Is escaped, but not visible when switched to Visual editing because there is 
   only markup and no text. If you add some text, like this for example:
 * `<div ad-type="leadboard" ad-data="picture">Some text whatever</div>`
 * ..then there will be some actual content to display visually.
 * Bottom line is that what you are reporting is default Visual-editor functionality.
   Best advice is to stick with the Plain-text editor when adding code and not switch
   to the visual editor.
 * I hope this all makes sense, let me know if I can provide any further infos.
    -  This reply was modified 5 years, 10 months ago by [Jeff Starr](https://wordpress.org/support/users/specialk/).
      Reason: changes angle brackets to entities
    -  This reply was modified 5 years, 10 months ago by [Jeff Starr](https://wordpress.org/support/users/specialk/).
      Reason: adds note
 *  Thread Starter [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/#post-13226591)
 * Thanks for the explanation but it doesn’t help.
 * If I use the default WP Gutenberg editor escaping works as it should. I select
   Prismatic block, paste code, select language and the pasted code is escaped as
   it should be. I can switch between visual and code editor and it just works.
 * When I activate the **Classic Editor** plugin the escaping doesn’t work as explained
   above.
    I use the plugin on all sites so it is an issue.
 * When I click on Prism.js code button `<>` a pop-up window opens, I select the
   language and paste the code.
    The code is NOT escaped! However, I remember few
   months ago this used to work.
 * And it should work otherwise you can’t use the plugin with the classic editor.
 * When the code is pasted into text editor (source code) it gets inserted into 
   the post as it is pasted. Of course, internally it may be escaped to display 
   properly on the editor page.
 * However, the problem is that when I paste the code into Prismatic window it doesn’t
   get escaped in the editor – but it should.
 * Please activate the **Classic Editor plugin** to reproduce the problem.
 * Thanks.
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/#post-13226684)
 * Absolutely will investigate as time allows. For this:
 * > However, I remember few months ago this used to work.
 * If you knew specifically which version(s) of the plugin that would help quite
   a bit.
 * > And it should work otherwise you can’t use the plugin with the classic editor.
 * Incorrect. I use Prismatic on my own sites using the Classic Editor. It works
   great. What does not work great, as explained in my previous reply, is switching
   between Plain Text and Visual editing modes. But just editing in plain-text the
   code is escaped just fine, I’ve written hundreds of code-related tutorials this
   way. In fact, I develop Prismatic and Disable Gutenberg specifically for the 
   purpose of sharing code snippets via the Classic Editor/Plain-Text.
 * > the problem is that when I paste the code into Prismatic window it doesn’t 
   > get escaped in the editor
 * This is a separate issue than what has been discussed above. Thanks for sharing
   this information. I will take a look and try to get code escaping to work in 
   the little popup window when using the Classic/Visual Editor.
 * > Please activate the Classic Editor plugin to reproduce the problem.
 * I use Disable Gutenberg because it has more options. But yes, I have recreated
   the issue using Classic/Visual Editor, thank you.
 *  Thread Starter [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/code-escaping/#post-13228223)
 * Sorry, I’m not sure when exatly it used to work.
    A lot of plugins and WP have
   been updated in the last few months.
 * Thanks for help.
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13651612)
 * Just to follow up with this, the reported issue is resolved in the next plugin
   update. Should be available later today or tomorrow. Thanks again for reporting,
   [@spacetime](https://wordpress.org/support/users/spacetime/).
 *  Thread Starter [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13657632)
 * Thank you very much for the update.
    But I didn’t notice any change. The code
   is still inserted unescaped.
 * I insert this code via the Prism button in visual editor:
 *     ```
       <script type="text/javascript">
       amzn_assoc_placement = "adunit0";
       amzn_assoc_search_bar = "true";
       amzn_assoc_tracking_id = "test-20";
       amzn_assoc_ad_mode = "manual";
       amzn_assoc_ad_type = "smart";
       amzn_assoc_marketplace = "amazon";
       amzn_assoc_region = "US";
       amzn_assoc_title = "My Amazon Picks";
       amzn_assoc_linkid = "78a14d38097e7c5b53b60cef1b7cb4e3";
       amzn_assoc_asins = "B01DOP5L4M,B071ZR9H5T,B00TV1A6IA,B001LUJBZ8";
       </script>
       <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"><;/script>
       ```
   
 * This is what is inserted – no escaping:
 *     ```
       <pre><code class="language-markup"><script type="text/javascript">
       amzn_assoc_placement = "adunit0";
       amzn_assoc_search_bar = "true";
       amzn_assoc_tracking_id = "test-20";
       amzn_assoc_ad_mode = "manual";
       amzn_assoc_ad_type = "smart";
       amzn_assoc_marketplace = "amazon";
       amzn_assoc_region = "US";
       amzn_assoc_title = "My Amazon Picks";
       amzn_assoc_linkid = "78a14d38097e7c5b53b60cef1b7cb4e3";
       amzn_assoc_asins = "B01DOP5L4M,B071ZR9H5T,B00TV1A6IA,B001LUJBZ8";
       </script>
       <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script></code></pre>
       ```
   
 * Consequently instead of the code text, the scripts get inserted into the content.
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13657720)
 * Using the latest version of Prismatic with Classic Editor Visual mode, I add 
   your example code snippet via the “Add Prism.js code” button. The results are
   escaped and display correctly. I can provide a video if necessary.
 *  Thread Starter [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13657766)
 * Well, it does not work in my case.
    I tried to disable plugins that may interfere
   and it seems that it does not work when Advanced Editor Tools is enabled.
 * Please check with [Advanced Editor Tools (previously TinyMCE Advanced)](https://wordpress.org/plugins/tinymce-advanced/)
   plugin activated.
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13657799)
 * I will look into it. Likewise, please try again with no other plugins active.
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13660364)
 * Just tested with Advanced Editor Tools and it works normally. Here are some screenshots
   that show what I am seeing:
    - [Adds code via Visual Editor](https://perishablepress.com/share/prismatic-visual-editor-code.png)
    - [Views code escaping via Text Editor](https://perishablepress.com/share/prismatic-text-editor-code.png)
    - [Views highlighted code on frontend](https://perishablepress.com/share/prismatic-frontend-code.png)
 * Again this is with Advanced Editor Tools active, on default WP using the default
   Twenty Fifteen theme. I get the same results with or without Advanced Editor 
   Tools.
 *  Thread Starter [Spacetime](https://wordpress.org/support/users/spacetime/)
 * (@spacetime)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13664085)
 * Tested again and now it works properly. It seems I had to flush the cache.
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13665299)
 * That’s great, glad you figured it out.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Code escaping’ is closed to new replies.

 * ![](https://ps.w.org/prismatic/assets/icon-256x256.png?rev=1521267)
 * [Prismatic](https://wordpress.org/plugins/prismatic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/prismatic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/prismatic/)
 * [Active Topics](https://wordpress.org/support/plugin/prismatic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/prismatic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/prismatic/reviews/)

 * 15 replies
 * 2 participants
 * Last reply from: [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/code-escaping/#post-13665299)
 * Status: resolved