Description
Currently every page passed through the post_page
event is parsed, while there could be ways to quickly skip it if there are no charts to process.
The optimization proposed in #41 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