zhaoterryy / mkdocs-pdf-export-plugin

An MkDocs plugin to export content pages as PDF files
MIT License
313 stars 44 forks source link

Fix download icon in material theme, fixes #83 #84

Closed timvink closed 3 years ago

timvink commented 4 years ago

Fixes download icon for material theme, #83

Demo:

image

timvink commented 4 years ago

Hee, thanks for letting me know!

I would like to reproduce this issue locally, but both mkdocs build and mkdocs serve work fine for me. Perhaps you have a minimal reproducable example? Or even better, an alternative solution?

Tim

rmueck commented 4 years ago

Hee, thanks for letting me know!

I would like to reproduce this issue locally, but both mkdocs build and mkdocs serve work fine for me. Perhaps you have a minimal reproducable example? Or even better, an alternative solution?

Tim

Hey Tim, as mentioned mkdocs build works like a charm. When i start mkdocs serve it initially looks fine, but the error occurs, when i try to navigate in the dev server site.

Cheers

rsansores commented 4 years ago

Can confirm @rmueck.

Same exception "Tried to write more data than Content-Lenght"

timvink commented 4 years ago

Thanks @rsansores .

I don't have time to work on this currently, hope to revisit in a couple of weeks or so. Feel free to pick up the PR :)

Kanaduchi commented 4 years ago

Hello! Any update on this PR? Does it work with latest version of mkdocs-material? (5.3.0)

I have a suggestion. You should specify parser for icon. Example: icon = BeautifulSoup(icon, 'html.parser')

timvink commented 4 years ago

Thanks @Kanaduchi for the pointer! Quite sure that will fix the HTTPOutputError.

I also fixed the icon size, which was wrong. If someone can confirm that it works for them as well, we can flag this as ready for merge to zhaoterryy.

Kanaduchi commented 4 years ago

Thanks @Kanaduchi for the pointer! Quite sure that will fix the HTTPOutputError.

I also fixed the icon size, which was wrong. If someone can confirm that it works for them as well, we can flag this as ready for merge to zhaoterryy.

I verified it locally.

One issue that I see is: image

I think you also need to remove a.string = '\uE2C4'

timvink commented 4 years ago

I think you also need to remove a.string = '\uE2C4'

That line was already removed. I now also removed any unnecessary attributes from the svg.

Renders correctly on chrome and safari, and latest mkdocs-material version:

image

Kanaduchi commented 4 years ago

Now it looks great! Thank you! Hope this PR will be merged soon

timvink commented 4 years ago

@zhaoterryy ready for merge 😃

timvink commented 3 years ago

I found & fixed another bug, present on master and also in this fix-download-icon branch

soup = BeautifulSoup(html, 'html.parser') actually does more than just parse the HTML, it also applies some 'fixes'. This leads to unintended side effects (other than inserting the button). For example, when used in combination with mknotebooks BeautifulSoup will break the HTML and the jupyter notebooks don't render correctly (on some browsers / platforms). Took a while to find that bug, but solution was easy: insert the button using basic python string manipulation.

zhaoterryy commented 3 years ago

@timvink cheers!