Priority: Normal
Current State: Closed
Released In: n/a
Target Release:
CODE_DP plugin doesn't properly show self-closing XML tags. Consider e.g. this snippet of .NET config XML:
%CODE_DP{lang="xml"}%
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
</sectionGroup>
</configSections>
%ENDCODE%
I was quite puzzled and confused when I saw how the CODE_DP plugin renders this on my Foswiki page - see attachment.
First of all, the CODE_DP plugin changes Uppercase letters to lowercase - which is bad, because .NET config
ARE case-sensitive!
And secondly - the self-closing XML tags aren't recognized as such - but instead, the same number of unnecessary closing XML tags are inserted, in the wrong place, too. What's the problem with the self-closing tags? This is 100% XML compliant syntax and CODE_DP should really recognize (and properly display) that.
--
MarcScheuner - 21 Feb 2013
If you look at the source on the
highlighters website, you can see that they needed to escape the xml tags to ensure it displays correctly. If you don't do this, the web browser tries to interpret the tags as HTMl, which is why you get this strange output.
The following seems to work fine:
%CODE_DP{lang="xml"}%
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
</sectionGroup>
</configSections>
%ENDCODE%
--
AndrewJones - 21 Feb 2013
AndrewJones is right that this is because of the need to escape. But if you use a textarea instead of a pre element then it works fine. Try:
%CODE_DP{lang="xml" el="textarea"}%
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
</sectionGroup>
</configSections>
%ENDCODE%
Now if I can only figure out how to make textarea the default...
--
JamesFrank - 08 Mar 2013
Since 3.0 the plugin uses <verbatim> tags instead of <pre>. So any xml will be properly escaped.
--
MichaelDaum - 04 Dec 2014