Defect #4472

Escape <code> tag

Added by Mikhail Yakshin over 12 years ago. Updated about 5 years ago.

Status:NewStart date:2009-12-22
Priority:NormalDue date:
Assignee:-% Done:


Category:Text formatting
Target version:Candidate for next minor release
Resolution: Affected version:


When using Textile-like wiki syntax, pre tag with code renders incorrectly. The simplest way to reproduce it is below:


It yields the same output as from:


What's more interesting, using @ syntax with code inside makes renderer go absolutely crazy:

It outputs mysterious line:

Related issues

Duplicated by Redmine - Defect #7375: <pre> ... </pre> doesn't escape wiki syntax correctly Closed 2011-01-19


#1 Updated by Etienne Massip about 11 years ago

  • Target version set to Candidate for next minor release

#2 Updated by Ivan Cenov over 10 years ago

before pre section

code code bold bold italic italic underline underline deleted deleted
after pre section

#3 Updated by Jonas De Meulenaere over 6 years ago

This issue remains a problem. I'm using Redmine 2.4.3.stable.

I try to display an XML response in a ticket. I use display my xml message nicely, I use the code class="xml" tag for syntax highlighting and the pre tag to keep the indenting. To do so nicely, I need to put the code tag within the pre tag. If I put the pre tag within the code tag, the code is not highlighted. This works well.

However there is no way to escape the code tag if you want to. Maybe since code is not a Textile tag, there is no way to escape it (using e.g. notextile). With or without the code highlighting, If my message itself contains a code tag, I do not manage to display it correctly.


<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="">

The problem lies IMHO in the fact that in different libraries/plugins are used (CodeRay & RedCloth/Textile) and Redmine does some patching on it, see in the bottom of formatter.rb .

#4 Updated by Jonas De Meulenaere about 5 years ago

  • Subject changed from <code> inside <pre> to Escape <code> tag

The only way to display a code tag is with HTML escaping (using &lt;), but only in clear text:


Within a code or a pre, it does not work:


All means with notextile don't work.

This is a simple code tag with notextile before


This is a simple code tag with notextile around


It doesn't work within a quote:


It doesn't work within a pre (with and without notextile):


It doesn't work within a pre + code (with and without notextile):


It doesn't work within == either:

== 1234 ==

Also available in: Atom PDF