Fix mathjax does not have time to create formula

This commit is contained in:
Kujiu 2023-09-17 18:51:22 +02:00
parent 093e629c70
commit fd0986908c
Signed by: kujiu
GPG key ID: ABBB2CAC6855599F
2 changed files with 9 additions and 2 deletions

View file

@ -5,6 +5,7 @@ from copy import deepcopy
from .pyppeteer_builder import PyppeteerPDFBuilder from .pyppeteer_builder import PyppeteerPDFBuilder
from typing import Dict, Any from typing import Dict, Any
from sphinx.application import Sphinx from sphinx.application import Sphinx
from sphinx.config import Config
from sphinx.util.osutil import make_filename from sphinx.util.osutil import make_filename
import pkg_resources import pkg_resources
@ -29,11 +30,12 @@ DEFAULT_PYPPETEER_ARGS = [
] ]
def on_config_inited(app, config): def on_config_inited(app, config: Config):
""" Change config on the fly """ """ Change config on the fly """
pdf_options = deepcopy(DEFAULT_PDF_OPTIONS) pdf_options = deepcopy(DEFAULT_PDF_OPTIONS)
pdf_options.update(app.config.pyppeteer_pdf_options) pdf_options.update(app.config.pyppeteer_pdf_options)
app.config.pyppeteer_pdf_options = pdf_options app.config.pyppeteer_pdf_options = pdf_options
app.set_html_assets_policy("always")
def setup(app: Sphinx) -> Dict[str, Any]: def setup(app: Sphinx) -> Dict[str, Any]:
@ -118,6 +120,11 @@ def setup(app: Sphinx) -> Dict[str, Any]:
'', '',
'pyppeteer' 'pyppeteer'
) )
app.add_config_value(
'pyppeteer_baseurl',
'#',
'pyppeteer'
)
return { return {
'version': __version__, 'version': __version__,

View file

@ -105,7 +105,7 @@ class PyppeteerPDFBuilder(SingleFileHTMLBuilder):
}) })
try: try:
page = await browser.newPage() page = await browser.newPage()
await page.goto(url) await page.goto(url, {"waitUntil": ["networkidle2"]})
await page.pdf(pdf_options) await page.pdf(pdf_options)
await browser.close() await browser.close()
finally: finally: