Skip to content

Commit

Permalink
Added Xonsh language support
Browse files Browse the repository at this point in the history
  • Loading branch information
jsquaredosquared authored and mwouts committed Apr 27, 2024
1 parent 12644e1 commit 9dd2439
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 4 deletions.
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.
8 changes: 4 additions & 4 deletions jupyterlab/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10812,21 +10812,21 @@ __metadata:

"typescript@patch:typescript@^3 || ^4#~builtin<compat/typescript>":
version: 4.9.5
resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=289587"
resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=23ec76"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68
checksum: ab417a2f398380c90a6cf5a5f74badd17866adf57f1165617d6a551f059c3ba0a3e4da0d147b3ac5681db9ac76a303c5876394b13b3de75fdd5b1eaa06181c9d
languageName: node
linkType: hard

"typescript@patch:typescript@~5.0.2#~builtin<compat/typescript>":
version: 5.0.4
resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin<compat/typescript>::version=5.0.4&hash=b5f058"
resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin<compat/typescript>::version=5.0.4&hash=85af82"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: d26b6ba97b6d163c55dbdffd9bbb4c211667ebebc743accfeb2c8c0154aace7afd097b51165a72a5bad2cf65a4612259344ff60f8e642362aa1695c760d303ac
checksum: bb309d320c59a26565fb3793dba550576ab861018ff3fd1b7fccabbe46ae4a35546bc45f342c0a0b6f265c801ccdf64ffd68f548f117ceb7f0eac4b805cd52a9
languageName: node
linkType: hard

Expand Down
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 9dd2439

Please sign in to comment.