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

Multi-times TOC are generated repeatly when markdown file has html included #49

Closed
guo1017138 opened this issue May 21, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@guo1017138
Copy link

Hi owners,

Thanks for the excellent plugin. I just found my table of contents are generated many times in my print page.

After debug, I found it caused by my including html several times as mkdocs supported:

--8<-- "./table_7.html"

And this plugin replace simply. This results generate_toc() called several times.
A possible fix will be only replace the last due to the previously ones may be included by html file.

@timvink
Copy link
Owner

timvink commented May 26, 2021

Hi @guo1017138 , thanks for reporting this!

I've tried building a minimal example to reproduce this, but have not succeeded yet.

Some questions:

  • Can you share your mkdocs.yml file? Specifically the plugins and markdown_extensions you are using
  • Can you share an example of one of these .html files? It is just a <table> or full <html> page?
  • Are you using the latest version of mkdocs, mkdocs-material and mkdocs-print-site-plugin ?
  • Which OS are you using? Which version of python (python -V)

@timvink timvink added the bug Something isn't working label May 26, 2021
@guo1017138
Copy link
Author

@timvink , Thank you. There are some sensitive data in the doc so I will create a demo mkdocs reproduce. Will upload the docs tar to this ticket once get reproduced.

@guo1017138
Copy link
Author

Hi @timvink , see the following link for the sample mkdocs project archive.

I include a test.html in index.md three times which caused the TOC was generated four times in print page.

htmltest.zip

@timvink
Copy link
Owner

timvink commented Sep 7, 2021

Sorry for the very late reply on this one. Finally got around to spent some time on debugging this. Your sample really helped there.

Turns out the snippets wraps content in these tags: <html><body>...</body></html>

I had (wrongly) assumed </body> would occur only once on the print-site page.

html = html.replace("</body>", print_site_js + "</body>")

There was also a second issue when enabling the instant loading feature from mkdocs-material, which I also managed to fix.

Will release the fix later today!

@timvink
Copy link
Owner

timvink commented Sep 7, 2021

Fixed in v1.2.4 !

@timvink timvink closed this as completed Sep 7, 2021
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