Skip to content

TOC contains empty entries #5

Open

Description

@ptitmain

Hi,
I just tried python-darkslide and it seems that it contains a bug I have patched years ago in the landslide project but that I forgot to upstream.
When increasing the hierarchy of the document, entries with high level generate an empty entry in the TOC. The code involved is:

            if slide_vars['level'] and slide_vars['level'] <= TOC_MAX_LEVEL:
                self.add_toc_entry(slide_vars['title'], slide_vars['level'],
                                   slide_number)
            else:
                # Put something in the TOC even if it doesn't have a title or level
               self.add_toc_entry(u"-", 1, slide_number)

And the patch I did:
ptitmain@e9d4dbd

Is this patch ok ?
If yes, can darkslide include such a patch ?
Best regards.

Activity

  1. ionelmc commented on Nov 12, 2017

    @ionelmc
    Owner

    Hmmm, perhaps we could have a better replacement? How about "(no title)"? What do you usually put in a slide without title?

  2. ionelmc commented on Nov 12, 2017

    @ionelmc
    Owner

    Another way is to leave it empty ("&nbsp;") - I think I like that one best. Eg:
    image

  3. ptitmain commented on Nov 12, 2017

    @ptitmain
    Author

    Ok, I have produced a MWE. The bugs seems to appear when a "----" is inserted between the first section and the first subsection: the 4th level of section appears empty in the TOC when hitting "t"...

    =====================
    Développement Android
    =====================
    
    .. |year| date:: %Y
    
    .. sectnum::
       :depth: 2
    
    Title page
    
    .. The bug is due to the following break:
    
    ----
    
    
    --------------
    Le SDK Android
    --------------
    
    .. contents::
       :local:
       :depth: 1
    
    ----
    
    
    Android
    -------
    
    Android test
    
    ----
    
    L'Operating System
    ~~~~~~~~~~~~~~~~~~
    
    OS Test
    
    ----
    
    Historique des versions
    ~~~~~~~~~~~~~~~~~~~~~~~
    
    Histo Test
    
    

    selection_082

  4. ionelmc commented on Nov 12, 2017

    @ionelmc
    Owner

    Looks like this here:
    image

    What version of docutils you have?

  5. ptitmain commented on Nov 12, 2017

    @ptitmain
    Author

    Sorry, wrong copy paste (one level more is needed):

    =====================
    Développement Android
    =====================
    
    .. |year| date:: %Y
    
    .. sectnum::
       :depth: 2
    
    Title page
    
    .. The bug is due to the following break:
    
    ----
    
    --------------
    Le SDK Android
    --------------
    
    .. contents::
       :local:
       :depth: 1
    
    ----
    
    
    Android
    -------
    
    Android test
    
    ----
    
    L'Operating System
    ~~~~~~~~~~~~~~~~~~
    
    OS Test
    
    ----
    
    Historique des versions
    ~~~~~~~~~~~~~~~~~~~~~~~
    
    Histo Test
    
    
  6. ptitmain commented on Nov 12, 2017

    @ptitmain
    Author

    docutils 0.12

    ii docutils-common 0.12+dfsg-1

  7. ionelmc commented on Nov 12, 2017

    @ionelmc
    Owner

    I see the problem, there's only support for 2 levels (TOC_MAX_LEVEL). It can be fixed.

  8. ptitmain commented on Nov 12, 2017

    @ptitmain
    Author

    Ok. Thus, probably the TOC should ignore other levels... or support more levels...
    In my opinion, there should be a parameter to control the TOC depth from the config file... (I see the variable in generator.py)

  9. ionelmc commented on Nov 12, 2017

    @ionelmc
    Owner

    I guess we could change it to 6 (as <h6> is max) and fix base.html/screen.css to support the extra nesting. You wanna do it?

    We'd need to use a jinja macro to adequately support the variable nesting in base.html (eg: http://jinja.pocoo.org/docs/2.9/templates/#macros).

  10. ptitmain commented on Nov 12, 2017

    @ptitmain
    Author

    Ok, I'll try to do it.

  11. ptitmain commented on Nov 12, 2017

    @ptitmain
    Author

    I am working on a patch.
    Still wondering what is the goal of the else branch:

                if slide_vars['level'] and slide_vars['level'] <= TOC_MAX_LEVEL:
                    self.add_toc_entry(slide_vars['title'], slide_vars['level'],
                                       slide_number)
                else:
                    # Put something in the TOC even if it doesn't have a title or level
                    self.add_toc_entry(u"-", 1, slide_number)
    

    In what case do we need an entry in the toc if there is no specified level ?

  12. ionelmc commented on Nov 12, 2017

    @ionelmc
    Owner

    I think the placeholder is there so you can navigate to the titleless slide via toc. I guess the else branch could be removed if the slide numbers are filled into the parent slide, eg:
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions