lzanini / mdbook-katex

A preprocessor for mdBook, rendering LaTex equations to HTML at build time.
MIT License
205 stars 34 forks source link

`mdbook-katex` being a renderer causes it to run twice #48

Closed SichangHe closed 1 year ago

SichangHe commented 1 year ago

mdbook-katex plays a role of a renderer since this.

The obvious downside is that the preprocessing task is run twice, first when mdbook invoke mdbook-katex as a preprocessor, second when mdbook invoke mdbook-katex as a renderer, so the time mdbook-katex runs doubles. On a numerical note, it used to take 3 seconds for me to build my notes, and it decreased to about 1.3 seconds after I made the performance improvement earlier today. As a comparison, removing mdbook-katex related processing from book.toml and building it yields 350ms. So, mdbook-katex is slow in this regard.

The real question is why @Matthewacon added the Renderer impl. I believe it must be of some deeper reason.

SichangHe commented 1 year ago

I figured out that the double rendering was actually because mdbook invoke the katex preprocessor when it invokes the katex renderer.