diff --git a/src/sphinx_thebe/__init__.py b/src/sphinx_thebe/__init__.py index 5c27da1..c875455 100644 --- a/src/sphinx_thebe/__init__.py +++ b/src/sphinx_thebe/__init__.py @@ -73,13 +73,13 @@ def init_thebe_core(app, env, docnames): # Add configuration variables THEBE_JS_URL = f"https://unpkg.com/thebe@{THEBE_VERSION}/lib/index.js" - thebe_config = f"""\ - const THEBE_JS_URL = "{ THEBE_JS_URL }" - const thebe_selector = "{ app.config.thebe_config['selector'] }" - const thebe_selector_input = "{ app.config.thebe_config['selector_input'] }" - const thebe_selector_output = "{ app.config.thebe_config['selector_output'] }" - """ - app.add_js_file(None, body=dedent(thebe_config)) + thebe_config_lines = [ + f"const THEBE_JS_URL = \"{ THEBE_JS_URL }\"", + f"const thebe_selector = \"{ app.config.thebe_config['selector'] }\"", + f"const thebe_selector_input = \"{ app.config.thebe_config['selector_input'] }\"", + f"const thebe_selector_output = \"{ app.config.thebe_config['selector_output'] }\"" + ] + app.add_js_file(None, body='; '.join(thebe_config_lines)) app.add_js_file(filename="sphinx-thebe.js", **{"async": "async"}) if config_thebe.get("always_load") is True: diff --git a/src/sphinx_thebe/_static/sphinx-thebe.js b/src/sphinx_thebe/_static/sphinx-thebe.js index 7626dbb..d92b1d3 100644 --- a/src/sphinx_thebe/_static/sphinx-thebe.js +++ b/src/sphinx_thebe/_static/sphinx-thebe.js @@ -4,7 +4,7 @@ var configureThebe = () => { // Load thebe config in case we want to update it as some point console.log("[sphinx-thebe]: Loading thebe config..."); - thebe_config = $('script[type="text/x-thebe-config"]')[0]; + thebe_config = document.querySelector("script[type=\"text/x-thebe-config\"]"); // If we already detect a Thebe cell, don't re-run if (document.querySelectorAll("div.thebe-cell").length > 0) { @@ -12,7 +12,7 @@ var configureThebe = () => { } // Update thebe buttons with loading message - $(".thebe-launch-button").each((ii, button) => { + document.querySelectorAll(".thebe-launch-button").forEach((button) => { button.innerHTML = `