From dc724a7097259d006019ce2cd5ce9dd051cc0c6f Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 28 Mar 2022 17:20:54 +0200 Subject: [PATCH] Cleanup query strings with urllib --- docs/index.rst | 2 +- src/jupyterlite_sphinx.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index a393683d..1abc5010 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,7 +12,7 @@ A Sphinx extension that provides utilities for embedding JupyterLite in your doc :width: 100% :height: 600px - print('Hello from a JupyterLite console!') + print("Hello from a JupyterLite console!") .. toctree:: :caption: Installation diff --git a/src/jupyterlite_sphinx.py b/src/jupyterlite_sphinx.py index 8d7835ca..1ae59345 100644 --- a/src/jupyterlite_sphinx.py +++ b/src/jupyterlite_sphinx.py @@ -4,6 +4,8 @@ from pathlib import Path +from urllib.parse import quote + import subprocess from docutils.parsers.rst import directives @@ -58,12 +60,14 @@ def __init__( def html(self): replite_options = self["replite_options"] - code_lines = [line.strip().replace(" ", "%20") for line in self["content"]] - code = "%0A".join(code_lines) + code_lines = [line.strip() for line in self["content"]] + code = "\n".join(code_lines) replite_options["code"] = code - options = "&".join([f"{key}={value}" for key, value in replite_options.items()]) + options = "&".join( + [f"{key}={quote(value)}" for key, value in replite_options.items()] + ) return ( f'