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 * Kujiu
* PtitGNU * 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): def on_config_inited(app, config):
""" Change config on the fly """ """ Change config on the fly """
@ -46,6 +52,11 @@ def setup(app: Sphinx) -> Dict[str, Any]:
DEFAULT_PDF_OPTIONS, DEFAULT_PDF_OPTIONS,
'pyppeteer' 'pyppeteer'
) )
app.add_config_value(
'pyppeteer_args',
DEFAULT_PYPPETEER_ARGS,
'pyppeteer'
)
app.add_config_value( app.add_config_value(
'pyppeteer_basename', 'pyppeteer_basename',
lambda self: make_filename(self.project), lambda self: make_filename(self.project),

View file

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