Item12401: CODE_DP cannot properly display self-closing XML tags

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release:
Applies To: Extension
Component: DpSyntaxHighlighterPlugin
Branches:
Reported By: MarcScheuner
Waiting For:
Last Change By: MichaelDaum
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"}%
&lt;configSections>
   &lt;sectionGroup name="elmah">
      &lt;section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      &lt;section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
   &lt;/sectionGroup>
&lt;/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
 

ItemTemplate edit

Summary CODE_DP cannot properly display self-closing XML tags
ReportedBy MarcScheuner
Codebase 1.0.5
SVN Range
AppliesTo Extension
Component DpSyntaxHighlighterPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release01x01Checkins
I Attachment Action Size Date Who Comment
CODE_DP_Plugin_rendering.pngpng CODE_DP_Plugin_rendering.png manage 17 K 21 Feb 2013 - 10:14 MarcScheuner  
Topic revision: r5 - 04 Dec 2014, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy