Fix mathjax does not have time to create formula
This commit is contained in:
parent
093e629c70
commit
fd0986908c
2 changed files with 9 additions and 2 deletions
|
@ -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__,
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue