Infrastructure
  1. Infrastructure
  2. INFRA-3938

Apache CMS does not create correctly nested TOC structure from document headings hierarchy

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Fix Version/s: Initial Clearing
    • Component/s: Website
    • Labels:
      None
    • Environment:
      Apache CMS

      Description

      I'm using the CMS to create our podling's web site. According to http://www.apache.org/dev/cmsref.html#markdown, I can use the [TOC] element to create a table of contents from the headers in the document, but I'm having a problem with it. Consider the following document:

          Title: TOC test
          
          The title above will generate an h1 element from the CMS scripts
          
          [TOC]
          
          ## I am the first h2
          lorem fubarum
          
          ## I am the second h2
          lorem fubarum
          
          ### I am the first h3
          lorem fubarum
          
          ## And I'm back to h2
          lorem fubarum

      The structure created by the TOC element does not match the hierarchy in the document. This is what I get, using a local copy of the CMS scripts, SVN update'd today (NB I hand-edited the indenting for clarity):

          <div id="content">
          <h1 class="title">TOC test</h1>
          <p>The title above will generate an h1 element from the CMS scripts</p>
          
          <div class="toc">
          <ul>
            <li><a href="#i_am_the_first_h2">I am the first h2</a>
               <ul>
                 <li><a href="#i_am_the_second_h2">I am the second h2</a>
                   <ul>
                     <li><a href="#i_am_the_first_h3">I am the first h3</a></li>
                   </ul>
                 </li>
                 <li><a href="#and_im_back_to_h2">And I'm back to h2</a></li>
               </ul>
            </li>
          </ul>
          </div>
          
          <h2 id="i_am_the_first_h2">I am the first h2</h2>
          <p>lorem fubarum</p>
          <h2 id="i_am_the_second_h2">I am the second h2</h2>
          <p>lorem fubarum</p>
          <h3 id="i_am_the_first_h3">I am the first h3</h3>
          <p>lorem fubarum</p>
          <h2 id="and_im_back_to_h2">And I'm back to h2</h2>
          <p>lorem fubarum</p>
          </div>

      It seems that the first encountered sub-head always becomes the parent of the other sub-heads of the document, regardless of their relative hierarchy levels. Since the `Title:` element will automatically create an h1 for the page, it seems natural to me that the remaining heads should start at h2, but I wonder if this is confusing the markdown TOC module.

        Activity

        Hide
        David Fisher added a comment - - edited
        What happens if the page uses the headerid extension's header_level parameter?

        header_level: 2
        Show
        David Fisher added a comment - - edited What happens if the page uses the headerid extension's header_level parameter? header_level: 2
        Hide
        Joe Schaefer added a comment -
        That's just the way the [TOC] stuff is implemented.
        Just start at the <h1> level and be happy.
        Show
        Joe Schaefer added a comment - That's just the way the [TOC] stuff is implemented. Just start at the <h1> level and be happy.

          People

          • Assignee:
            Unassigned
            Reporter:
            Ian Dickinson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development