Skip to content

Commit e7fa127

Browse files
authored
Merge pull request #42 from martinRenou/remove_empty_lines
Replite code: Remove empty lines but not indentation
2 parents 9d98a8e + 0f3741f commit e7fa127

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
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

docs/replite.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This directive takes the same options as the ``replite`` package, see https://gi
66

77
.. code-block:: rst
88
9-
.. replite::
10-
:kernel: python
11-
:height: 600px
9+
.. replite::
10+
:kernel: python
11+
:height: 600px
1212
1313
import matplotlib.pyplot as plt
1414
import numpy as np
@@ -24,12 +24,12 @@ This directive takes the same options as the ``replite`` package, see https://gi
2424
:kernel: python
2525
:height: 600px
2626

27-
import matplotlib.pyplot as plt
28-
import numpy as np
27+
import matplotlib.pyplot as plt
28+
import numpy as np
2929

30-
x = np.linspace(0, 2 * np.pi, 200)
31-
y = np.sin(x)
30+
x = np.linspace(0, 2 * np.pi, 200)
31+
y = np.sin(x)
3232

33-
fig, ax = plt.subplots()
34-
ax.plot(x, y)
35-
plt.show()
33+
fig, ax = plt.subplots()
34+
ax.plot(x, y)
35+
plt.show()

src/jupyterlite_sphinx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def __init__(
6060
def html(self):
6161
replite_options = self["replite_options"]
6262

63-
code_lines = [line.strip() for line in self["content"]]
63+
# Remove empty lines
64+
code_lines = ["" if not line.strip() else line for line in self["content"]]
6465
code = "\n".join(code_lines)
6566

6667
replite_options["code"] = code

0 commit comments

Comments
 (0)