Issue #561 resolved

"toc" macro seems broken (BB-678)

craiv avatarcraiv created an issue

Hi there, I am not able to use the

macro in the wiki (I got an error message: Wiki macro error: 'NoneType' object has no attribute 'endswith' when I insert
on top of a wiki page which has structured headings.

Bug example can be seen at http://bitbucket.org/craiv/ibelieve/wiki/ (space is private).

Thanks for your time :)

Comments (22)

  1. alu

    Not sure if this is the same issue that I had, but that error only appears for me in preview mode.

    When first trying it out, I previewed the page and thought, I must be using it wrong - but it seems to work correctly when not in preview mode.

  2. craiv

    Jesper Avôt, I thought you could see private spaces, that's why I linked it. :)

    As alu stated, the error is only in preview mode. As I save, I get a weird unordered list, with funny markup:

    <p><div class="toc"> 
    <ul> 
    <li><a href="#">=</a></li> 
    <li><a href="#">=</a></li> 
    <li><a href="#">=</a></li> 
    <li><a href="#">=</a></li> 
    <li><a href="#">=</a></ul></div></p> 
    

    Being like that, I tried to create a new page, say "/wiki/newpage". I filled it with very basic content:

    <<toc>>
    
    = A heading
    here is something about this test page:
    
    == This is only a test page, I said
    ... but the table of contents is a very good feature. If only it worked :P
    

    in this case, the result is simply nothing (except for the error message in the preview).

  3. Jesper Nøhr

    No, there's nothing special about my account. I can't see private things.

    Can you try to have your headlines in "full" style? i.e. = foo= instead of just = foo. Would help me debug.

    The preview bug needs to be fixed, of course.

  4. craiv

    Sure! :)

    <<toc>>
    
    
    = A heading =
    here is something about this test page:
    
    == This is only a test page, I said ==
    ... but the table of contents is a very good feature. If only it worked :P
    

    renders in the preview with the same error message I posted.

    But, in the saved view, it renders correctly. So, the problem is with "short" headlines only. (As a temporary workaround I'll change my main page with full headings)

    Thanks again ;)

  5. rabarberski

    I confirm the findings about the buggy toc behavior.

    In addition, I've noticed that my toc sometimes contains weird entries. When I make sure that each heading has exactly one space before and after the title words, things are fine.

    So, this is fine:

    == This is a dummy heading ==
    

    But all of the following goes boink:

    ==This is a dummy heading ==
    == This is a dummy heading==
    ==This is a dummy heading==
    
  6. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.