Skip to content

Commit

Permalink
Add Xonsh support (#1213)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsquaredosquared committed Apr 28, 2024
1 parent fe2ba5e commit ef4a2b7
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Jupytext ChangeLog
==================

1.16.2-dev (2024-03-??)
1.16.2-dev (2024-05-??)
-------------------

**Added**
- Added support for Xonsh notebooks ([#1213](https://github.com/mwouts/jupytext/pull/1213)) - thanks to [Jeffrey Odongo](https://github.com/jsquaredosquared) for this contribution

**Changed**
- Temporary text notebooks for the `--pipe` or `--check` commands are now created in the notebook directory ([#1206](https://github.com/mwouts/jupytext/issues/1206))
- Jupytext uses the standard library `tomllib` in Python 3.11, or `tomli` in Python 3.10 or older, to match JupyterLab's dependencies ([#1195](https://github.com/mwouts/jupytext/issues/1195))
Expand Down
1 change: 1 addition & 0 deletions docs/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ Jupytext works with notebooks in any of the following languages:
- TypeScript
- Wolfram Language
- Note that Jupytext uses the non-standard `.wolfram` file extension for Wolfram Language files to avoid conflicts with Matlab.
- Xonsh

Extending Jupytext to more languages should be easy, see the sections on [contributing to](contributing.md) and [developing](developing.md) Jupytext.
1 change: 1 addition & 0 deletions src/jupytext/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"comment": "/*",
"comment_suffix": "*/",
},
".xsh": {"language": "xonsh", "comment": "#"},
}

_COMMENT_CHARS = [
Expand Down
58 changes: 58 additions & 0 deletions tests/data/notebooks/inputs/ipynb_xonsh/xonsh_example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"35196\n"
]
}
],
"source": [
"len($(curl -L https://xon.sh))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"xonsh_example.ipynb\n",
"\n"
]
}
],
"source": [
"for filename in `.*`:\n",
" print(filename)\n",
" du -sh @(filename)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Xonsh",
"language": "xonsh",
"name": "xonsh"
},
"language_info": {
"codemirror_mode": "shell",
"file_extension": ".xsh",
"mimetype": "text/x-sh",
"name": "xonsh",
"pygments_lexer": "xonsh",
"version": "0.14.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
17 changes: 17 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_Rmd/xonsh_example.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
jupyter:
kernelspec:
display_name: Xonsh
language: xonsh
name: xonsh
---

```{xonsh}
len($(curl -L https://xon.sh))
```

```{xonsh}
for filename in `.*`:
print(filename)
du -sh @(filename)
```
15 changes: 15 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_hydrogen/xonsh_example.xsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ---
# jupyter:
# kernelspec:
# display_name: Xonsh
# language: xonsh
# name: xonsh
# ---

# %%
len($(curl -L https://xon.sh))

# %%
for filename in `.*`:
print(filename)
du -sh @(filename)
17 changes: 17 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_md/xonsh_example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
jupyter:
kernelspec:
display_name: Xonsh
language: xonsh
name: xonsh
---

```xonsh
len($(curl -L https://xon.sh))
```

```xonsh
for filename in `.*`:
print(filename)
du -sh @(filename)
```
16 changes: 16 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_myst/xonsh_example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
kernelspec:
display_name: Xonsh
language: xonsh
name: xonsh
---

```{code-cell} xonsh
len($(curl -L https://xon.sh))
```

```{code-cell} xonsh
for filename in `.*`:
print(filename)
du -sh @(filename)
```
15 changes: 15 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_percent/xonsh_example.xsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ---
# jupyter:
# kernelspec:
# display_name: Xonsh
# language: xonsh
# name: xonsh
# ---

# %%
len($(curl -L https://xon.sh))

# %%
for filename in `.*`:
print(filename)
du -sh @(filename)
13 changes: 13 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_script/xonsh_example.xsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ---
# jupyter:
# kernelspec:
# display_name: Xonsh
# language: xonsh
# name: xonsh
# ---

len($(curl -L https://xon.sh))

for filename in `.*`:
print(filename)
du -sh @(filename)

0 comments on commit ef4a2b7

Please sign in to comment.