Skip to content

Conversation

@jjallaire
Copy link
Collaborator

@jjallaire jjallaire commented Sep 4, 2023

This PR implements support for rendering Jupyter percent scripts, which are a convention for encoding a notebook within an ordinary script file. For example, consider the following notebook.py:

# %% [markdown]
# Some **markdown**

# %%
1 + 1

You can also include markdown inside a multi-line quote. For example:

# %% [markdown]
"""
Some **markdown**
"""

Jupyter percent scripts are currently supported by a wide variety of tools including VS Code, Visual Studio, PyCharm, Spyder, and Hydrogen. See the Jupytext documentation on percent scripts for additional details: https://jupytext.readthedocs.io/en/latest/formats-scripts.html

This PR implements support for Python, Julia, and R. There is now a claimsFile() method on engines (which replaces claimsExtension()) that is used to determine if a script should be targeted as a percent script.

@cderv It would be great if you could add comparable support for Knitr spin() using the claimsFile() method (which will need to look inside the R script to see if it uses spin() conventions).

@pankgeorg Once this lands you can update your Pluto engine to implement claimsFile() (you'll want to look inside the file to detect whether it is a Pluto notebook)

@jjallaire jjallaire merged commit 3453f29 into main Sep 4, 2023
@jjallaire jjallaire deleted the feature/jupyter-percent-scripts branch September 4, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants