Skip to content

Replite code: Remove empty lines but not indentation #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions docs/replite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This directive takes the same options as the ``replite`` package, see https://gi

.. code-block:: rst

.. replite::
:kernel: python
:height: 600px
.. replite::
:kernel: python
:height: 600px

import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -24,12 +24,12 @@ This directive takes the same options as the ``replite`` package, see https://gi
:kernel: python
:height: 600px

import matplotlib.pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2 * np.pi, 200)
y = np.sin(x)
x = np.linspace(0, 2 * np.pi, 200)
y = np.sin(x)

fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()
fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()
3 changes: 2 additions & 1 deletion src/jupyterlite_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def __init__(
def html(self):
replite_options = self["replite_options"]

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

replite_options["code"] = code
Expand Down