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 rendering issue #59

Closed
majkinetor opened this issue Nov 30, 2021 · 6 comments
Closed

TOC rendering issue #59

majkinetor opened this issue Nov 30, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@majkinetor
Copy link

majkinetor commented Nov 30, 2021

TOC part with sections is rendered totally differently from the other TOC elements.

Take a look at "Extra" in the TOC here:

image

Here are the problems:

  1. It can't be clicked
  2. It has quote line in it ?
  3. It is separated from other TOC elements.

All in all, it looks very ugly, especially with more of them.

@timvink timvink added the bug Something isn't working label Nov 30, 2021
@timvink
Copy link
Owner

timvink commented Nov 30, 2021

Yes, definitely a bug with the section headings. I'll look into it.

Just a quite check, because I couldn't find it, are you using the latest version of this plugin?

Also, which version of mkdocs-material are you using (v8 just came out, might be related) ?

@majkinetor
Copy link
Author

Yeah, all latest.

FYI, I am always using the same demo project to show you to the problems. Its base on mm-docs and you can see all versions in requirements.txt

@majkinetor
Copy link
Author

(v8 just came out, might be related) ?

No, this happens since first version of this plugin.

@timvink
Copy link
Owner

timvink commented Dec 2, 2021

So the root cause is that in your project, the first page under the new 'Extra' section (vars.md) does not start with a level 1 heading:

https://github.com/majkinetor/mm-docs-template/blob/02d7823bf339f2f91a7849911fdae8172b7bbe33/source/docs/vars.md?plain=1#L6

This plugin has quite some logic to support sections, even nested sections, like the one in the screenshot below.

Things got super complex if a new page does not start with a new level 1 heading and so I required all pages to start with heading 1. That is also your solution:

The real problem is that this error wasn't raised:

# We need to validate that the first heading on each page is a h1
# This is required for the print page table of contents and enumeration logic
if self.config.get("add_table_of_contents") or self.config.get("enumerate_headings"):
if page in self.all_pages_in_nav:
match = re.search(r"\<h[0-6]", html)
if match:
if not match.group() == "<h1":
msg = f"The page {page.title} ({page.file.src_path}) does not start with a level 1 heading."
msg += "This is required for print page Table of Contents and/or enumeration of headings."
raise AssertionError(msg)

I tracked down & fixed that bug, will release a new version soon.

timvink added a commit that referenced this issue Dec 2, 2021
@timvink
Copy link
Owner

timvink commented Dec 2, 2021

Should be fixed in v2.1 let me know :)

@majkinetor
Copy link
Author

It works:

ERROR - Error reading page 'vars.md': The page Variables (vars.md) does not start with a level 1 heading.This is required for print page Table of Contents and/or enumeration of headings.

Adding it looks good.

Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants