adrienbrignon / mkdocs-exporter

⚡ The fastest and most configurable plugin for MkDocs, allowing seamless export of individual pages or entire documentation as PDF documents.
https://adrienbrignon.github.io/mkdocs-exporter/
MIT License
71 stars 2 forks source link

Rendering pages with MathJax as PDF #10

Closed 2xsaiko closed 9 months ago

2xsaiko commented 9 months ago

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?

adrienbrignon commented 9 months ago

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.

adrienbrignon commented 9 months ago

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.

2xsaiko commented 9 months ago

Thanks a lot, it works!

2xsaiko commented 9 months ago

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.

adrienbrignon commented 9 months ago

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.