Skip to content

Commit dea4ac0

Browse files
authored
Merge pull request #41 from martinRenou/cleanup_query_options
Cleanup query strings with urllib
2 parents b0e17a9 + dc724a7 commit dea4ac0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A Sphinx extension that provides utilities for embedding JupyterLite in your doc
1212
:width: 100%
1313
:height: 600px
1414

15-
print('Hello from a JupyterLite console!')
15+
print("Hello from a JupyterLite console!")
1616

1717
.. toctree::
1818
:caption: Installation

src/jupyterlite_sphinx.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from pathlib import Path
66

7+
from urllib.parse import quote
8+
79
import subprocess
810

911
from docutils.parsers.rst import directives
@@ -58,12 +60,14 @@ def __init__(
5860
def html(self):
5961
replite_options = self["replite_options"]
6062

61-
code_lines = [line.strip().replace(" ", "%20") for line in self["content"]]
62-
code = "%0A".join(code_lines)
63+
code_lines = [line.strip() for line in self["content"]]
64+
code = "\n".join(code_lines)
6365

6466
replite_options["code"] = code
6567

66-
options = "&".join([f"{key}={value}" for key, value in replite_options.items()])
68+
options = "&".join(
69+
[f"{key}={quote(value)}" for key, value in replite_options.items()]
70+
)
6771

6872
return (
6973
f'<iframe src="{JUPYTERLITE_DIR}/repl/index.html?{options}"'

0 commit comments

Comments
 (0)