Title: Sourcecode with code tags (i.e., nested code tags)
Last modified: August 22, 2020

---

# Sourcecode with code tags (i.e., nested code tags)

 *  Resolved [hiroprot](https://wordpress.org/support/users/hiroprot/)
 * (@hiroprot)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/sourcecode-with-tags-i-e-nested-tags/)
 * I want to show HTML source code that contains code tags. As always, I enclose
   the source code in code tags, which results in nested code tags. This does not
   display correctly in the frontend because the inner closing code tag is not escaped.
 * Example via screenshots to prevent character escaping by the forum:
    - Page source in the (classic) editor: [https://i.imgur.com/eHE1rrv.png](https://i.imgur.com/eHE1rrv.png)
    - Resulting frontend view (closing code tag not displayed): [https://i.imgur.com/jCx6cUQ.png](https://i.imgur.com/jCx6cUQ.png)
    - Page source of the frontend page (inner closing code tag not escaped): [https://i.imgur.com/sEA59kZ.png](https://i.imgur.com/sEA59kZ.png)
 * My configuration:
    - Prismatic 2.5
    - Prism.js library
    - Code escaping in frontend and admin area
    - WordPress classic editor
 *  -  This topic was modified 5 years, 9 months ago by [hiroprot](https://wordpress.org/support/users/hiroprot/).
    -  This topic was modified 5 years, 9 months ago by [hiroprot](https://wordpress.org/support/users/hiroprot/).

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

 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/sourcecode-with-tags-i-e-nested-tags/#post-13298485)
 * Thanks for reporting. I can confirm this is a bug with the latest version of 
   Prismatic. I have added to the to-do list and will try to resolve for the next
   plugin update. Thank you for reporting, [@hiroprot](https://wordpress.org/support/users/hiroprot/).
 *  Thread Starter [hiroprot](https://wordpress.org/support/users/hiroprot/)
 * (@hiroprot)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/sourcecode-with-tags-i-e-nested-tags/#post-13298494)
 * Many thanks for the super-quick response. I’m looking forward to version 2.6 
   😉
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/sourcecode-with-tags-i-e-nested-tags/#post-13651551)
 * Just to follow up. I’ve been looking into this, some notes:
    - The code-escaping regex fails for one case: nested code tags
    - The regex basically is `<code>(.*)</code>` so when nested, the second/outer`
      <code>` tag is ignored
 * Rewriting the current regex (regular expression) to account for nested code tags
   will require more time than I currently possess, it’s way more complex and requires
   much testing, etc.
 * So what I’m thinking at this point is to provide a workaround, just a simple 
   shortcode to account for when nested code tags are required:
 * `[prismatic_code][/prismatic_code]`
 * **Edit:** Apparently it’s not possible to include HTML entities here in the forums.
   So I am replacing this part of my reply with a [screenshot](https://perishablepress.com/share/prismatic-nested-code-tags.png)
   showing the original plain-text message. Basically you need to use HTML entities
   for the code tag brackets.
 * It’s not ideal but wanted to provide a solution until there is time to rework
   the core regex. I hope it helps, [@hiroprot](https://wordpress.org/support/users/hiroprot/).
   Thanks again for reporting, and feel free to post again with any further comments,
   etc.
    -  This reply was modified 5 years, 6 months ago by [Jeff Starr](https://wordpress.org/support/users/specialk/).
      Reason: Edits code, adds link to image
    -  This reply was modified 5 years, 6 months ago by [Jeff Starr](https://wordpress.org/support/users/specialk/).
      Reason: clarity
 *  Thread Starter [hiroprot](https://wordpress.org/support/users/hiroprot/)
 * (@hiroprot)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/sourcecode-with-tags-i-e-nested-tags/#post-13651561)
 * Thanks, a workaround is certainly helpful!
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/sourcecode-with-tags-i-e-nested-tags/#post-13651566)
 * I added a screenshot that shows better the required HTML entities. Cheers [@hiroprot](https://wordpress.org/support/users/hiroprot/)!

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

The topic ‘Sourcecode with code tags (i.e., nested code tags)’ 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/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [escaping](https://wordpress.org/support/topic-tag/escaping/)

 * 5 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/sourcecode-with-tags-i-e-nested-tags/#post-13651566)
 * Status: resolved