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

Do not parse HTML pages if we know there are no mermaid charts #41

Merged
merged 2 commits into from Jul 22, 2021

Conversation

ribetm
Copy link
Contributor

@ribetm ribetm commented Jul 19, 2021

Fix #42.

This optimization should greatly benefit large documentations with limited use of this plugin.
It does not run BeautifulSoup on every pages produced by mkdocs and instead checks first for the word mermaid textually.
This change allowed a 600 pages documentation (only 1 page with charts) to build in 60s instead of 240s, as about 70% of the total computing time was spent in mermaid's post_page event.

This PR should not have any meaningful consequences on the generated files, except for the fact that pages not processed by mermaid will not be reformatted by bs4 (white lines, indentation and attributes re-ordering). This is probably not an issue since it was mostly a side-effect and actually means keeping the output format of base mkdocs.

Three possibilities:

  • Page with charts: no changes in performance or output
  • Pages with the word mermaid but no charts: no changes in performance or output, some computing time still "wasted"
  • Pages without the word mermaid: much faster processing but output format changed

@fralau
Copy link
Owner

fralau commented Jul 19, 2021

@ribetm Easily one of the best PRs I have seen so far (beauty is in the simplicity). 👏

Could I ask two things form you?

  1. Create a github issue and connect this PR to it.
  2. Bump the minor-minor version number in setup.py.

Thanks a lot!

@fralau fralau merged commit 1085a9a into fralau:master Jul 22, 2021
@fralau fralau mentioned this pull request Jul 25, 2021
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

Successfully merging this pull request may close these issues.

Skip parsing of HTML pages when possible
2 participants