Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOC contains empty entries #5

Open
ptitmain opened this issue Nov 12, 2017 · 12 comments
Open

TOC contains empty entries #5

ptitmain opened this issue Nov 12, 2017 · 12 comments

Comments

@ptitmain
Copy link

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.

@ionelmc
Copy link
Owner

ionelmc commented Nov 12, 2017

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

@ionelmc
Copy link
Owner

ionelmc commented Nov 12, 2017

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

@ptitmain
Copy link
Author

ptitmain commented Nov 12, 2017

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

@ionelmc
Copy link
Owner

ionelmc commented Nov 12, 2017

Looks like this here:
image

What version of docutils you have?

@ptitmain
Copy link
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

@ptitmain
Copy link
Author

docutils 0.12

ii docutils-common 0.12+dfsg-1

@ionelmc
Copy link
Owner

ionelmc commented Nov 12, 2017

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

@ptitmain
Copy link
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)

@ionelmc
Copy link
Owner

ionelmc commented Nov 12, 2017

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).

@ptitmain
Copy link
Author

Ok, I'll try to do it.

@ptitmain
Copy link
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 ?

@ionelmc
Copy link
Owner

ionelmc commented Nov 12, 2017

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants