Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-15289

HTML headings are not correctly rendered in templates

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 9.8.1
    • Rendering
    • None
    • Unknown

    Description

      In our case we have documents with some macros and the macros are using templates for their rendering.
      I noticed that if a document content contains html headings (H1, H2, H3 ...) and if there are multipe headings with the same text, the headings IDs are not correctly rendered when the headings are coming from templates.

      It seems that the templates are not taking in consideration the other headings generated outside of the template.

      The headings IDs are generated based on the heading's text after spaces and special characters are removed, normally when we have multiple headings with the same text in a document, the headings IDs are incremented.

      After some tests I managed to reproduce the issue using a simple template, follow steps below:

      1. Create a wiki page
      2. Set the page content with the code below, save and view:
        == headings from document content ==
        
        ===Economie===
        
        ===Economie===
        
        ===Economie===
        
        == headings from template ==
        
        {\{template name="mytemplate.vm"/}}
        

      The code of the template 'mytemplate.vm':

      ##!source.syntax=xwiki/2.1
      ===Economie===
      ===Economie===
      ===Economie===
      

      Expected result: the rendered content should looks like:

      <h2 id="Hheadingsfromdocumentcontent" class="wikigeneratedid"><span>headings from document content</span></h2>
      <h3 id="HEconomie" class="wikigeneratedid"><span>Economie</span></h3>
      <h3 id="HEconomie-1" class="wikigeneratedid"><span>Economie</span></h3>
      <h3 id="HEconomie-2" class="wikigeneratedid"><span>Economie</span></h3>
      <h2 id="Hheadingsfromtemplate" class="wikigeneratedid"><span>headings from template</span></h2>
      <h3 id="HEconomie-3" class="wikigeneratedid wikigeneratedheader"><span>Economie</span></h3>
      <h3 id="HEconomie-4" class="wikigeneratedid wikigeneratedheader"><span>Economie</span></h3>
      <h3 id="HEconomie-5" class="wikigeneratedid wikigeneratedheader"><span>Economie</span></h3>
      

      Current result:

      <h2 id="Hheadingsfromdocumentcontent" class="wikigeneratedid"><span>headings from document content</span></h2>
      <h3 id="HEconomie" class="wikigeneratedid"><span>Economie</span></h3>
      <h3 id="HEconomie-1" class="wikigeneratedid"><span>Economie</span></h3>
      <h3 id="HEconomie-2" class="wikigeneratedid"><span>Economie</span></h3>
      <h2 id="Hheadingsfromtemplate" class="wikigeneratedid"><span>headings from template</span></h2>
      <h3 id="HEconomie" class="wikigeneratedid wikigeneratedheader"><span>Economie</span></h3>
      <h3 id="HEconomie-1" class="wikigeneratedid wikigeneratedheader"><span>Economie</span></h3>
      <h3 id="HEconomie-2" class="wikigeneratedid wikigeneratedheader"><span>Economie</span></h3>
      

      As we can see from the exemple the headings IDs numbering is working correclty inside the template but it is not taking in consideration the headings outside the template.

      Note that the same error appears when we use the include macro to include a page that contains html headings.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mouhb Mohamed Boussaa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: