adrienbrignon / mkdocs-exporter

📝 MkDocs Exporter is a powerful plugin for MkDocs that enables seamless conversion of single pages and/or the entire documentation into professional PDF files.

Home Page:https://adrienbrignon.github.io/mkdocs-exporter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rendering pages with MathJax as PDF

2xsaiko opened this issue · comments

I have a document I'm trying to render as PDF including LaTeX text, but the PDF only shows the raw LaTeX commands. MathJax is configured like here. I feel like this should work already considering this uses a browser to render the page, though. Do I need something else to make this work?

Hello @2xsaiko,
Thank you for submitting an issue.

I will investigate the issue you are facing and provide you with a solution in a timely manner.


Edit:

To keep you updated, I am working on the plugin's next version, where your issue (among others) will be resolved.

I firmly believe that employing a server-side browser for PDF rendering is excessively burdensome, particularly considering that the end-users are accessing the documentation through a browser capable of generating PDFs as well.

In the upcoming version, I will centralize the majority of the processing within the browser itself. However, the capability to save PDF documents to the filesystem during the build phase will be maintained. This functionality will be streamlined, as the primary logic is already integrated within the webpage.

Hello @2xsaiko,

I'm getting back to you to announce the release of version 5.0.0.
You can now render MathJax expressions in your PDF documents, you can find some samples here :)

The following steps are required to enable rendering:

After following these steps, MkDocs Exporter will automatically invoke the render function of the MkDocsExporter object, thus rendering MathJax expressions.

Feel free to get back to me if needed.

Thanks a lot, it works!

I did find one document that caused it to hang for a minute and then fail with

playwright._impl._api_types.TimeoutError: Timeout 60000ms exceeded.
=========================== logs ===========================
waiting for locator("body[mkdocs-exporter=\"true\"]") to be visible
============================================================

which was caused by it containing $$\require{cancel}$$. But that also throws an error in the console if you view the HTML in a browser and it didn't seem to be needed anyway so I just removed it. Probably just a broken document on my part.

I did find one document that caused it to hang for a minute and then fail with

playwright._impl._api_types.TimeoutError: Timeout 60000ms exceeded.
=========================== logs ===========================
waiting for locator("body[mkdocs-exporter=\"true\"]") to be visible
============================================================

which was caused by it containing $$\require{cancel}$$. But that also throws an error in the console if you view the HTML in a browser and it didn't seem to be needed anyway so I just removed it. Probably just a broken document on my part.

Yes, probably that.

However, I should probably implement error handling in the library itself. So when the render function throws, the rendering still continues but with a warning, avoiding the timeout from being reached.

Thank your for the feedback, it is very much appreciated.