Can overwrite pyppeteer args

This is an anonymous contribution
This commit is contained in:
Kujiu 2023-09-17 15:13:59 +02:00
parent e850eb4960
commit 093e629c70
Signed by: kujiu
GPG Key ID: ABBB2CAC6855599F
3 changed files with 14 additions and 5 deletions

View File

@ -2,3 +2,4 @@
* Kujiu
* PtitGNU
* Anonymous contributor

View File

@ -22,6 +22,12 @@ DEFAULT_PDF_OPTIONS = {
}
}
DEFAULT_PYPPETEER_ARGS = [
'--allow-file-access-from-file',
'--disable-web-security',
'--no-sandbox',
]
def on_config_inited(app, config):
""" Change config on the fly """
@ -46,6 +52,11 @@ def setup(app: Sphinx) -> Dict[str, Any]:
DEFAULT_PDF_OPTIONS,
'pyppeteer'
)
app.add_config_value(
'pyppeteer_args',
DEFAULT_PYPPETEER_ARGS,
'pyppeteer'
)
app.add_config_value(
'pyppeteer_basename',
lambda self: make_filename(self.project),

View File

@ -23,7 +23,7 @@ class PyppeteerPDFBuilder(SingleFileHTMLBuilder):
search = False
def _get_translations_js(self) -> str:
return
return ""
def copy_translation_js(self) -> None:
return
@ -101,10 +101,7 @@ class PyppeteerPDFBuilder(SingleFileHTMLBuilder):
"""
# Disable security to allow SVG use.
browser = await pyppeteer.launch({
'args': [
'--allow-file-access-from-file',
'--disable-web-security',
]
'args': self.config.pyppeteer_args,
})
try:
page = await browser.newPage()