Skip to content
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

add Tcl as a supported language #930

Merged
merged 1 commit into from
Mar 20, 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
1 change: 1 addition & 0 deletions docs/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ Jupytext works with notebooks in any of the following languages:
- Script of Script
- TypeScript
- Haskell
- Tcl

Extending Jupytext to more languages should be easy, see the sections on [contributing to](contributing.md) and [developing](developing.md) Jupytext.
2 changes: 2 additions & 0 deletions jupytext/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"sql",
"cython",
"haskell",
"tcl",
]

# Supported file extensions (and languages)
Expand Down Expand Up @@ -65,6 +66,7 @@
"comment_suffix": "*)",
}, # OCaml only has block comments
".hs": {"language": "haskell", "comment": "--"},
".tcl": {"language": "tcl", "comment": "#"},
}

_COMMENT_CHARS = [
Expand Down
86 changes: 86 additions & 0 deletions tests/notebooks/ipynb_tcl/tcl_test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Assign Values"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a = 1\n"
]
}
],
"source": [
"set a 1\n",
"puts \"a = $a\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loop"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I inside first loop: 0\n",
"I inside first loop: 1\n",
"I inside first loop: 2\n",
"I inside first loop: 3\n",
"I inside first loop: 4\n",
"I inside first loop: 5\n",
"I inside first loop: 6\n",
"I inside first loop: 7\n",
"I inside first loop: 8\n",
"I inside first loop: 9\n"
]
}
],
"source": [
"for {set i 0} {$i < 10} {incr i} {\n",
" puts \"I inside first loop: $i\"\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Tcl",
"language": "tcl",
"name": "tcljupyter"
},
"language_info": {
"file_extension": ".tcl",
"mimetype": "txt/x-tcl",
"name": "tcl",
"version": "8.6.11"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
26 changes: 26 additions & 0 deletions tests/notebooks/mirror/ipynb_to_Rmd/tcl_test.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
jupyter:
kernelspec:
display_name: Tcl
language: tcl
name: tcljupyter
---

# Assign Values

```{tcl}
set a 1
puts "a = $a"
```

# Loop

```{tcl}
for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}
```

```{tcl}

```
24 changes: 24 additions & 0 deletions tests/notebooks/mirror/ipynb_to_hydrogen/tcl_test.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ---
# jupyter:
# kernelspec:
# display_name: Tcl
# language: tcl
# name: tcljupyter
# ---

# %% [markdown]
# # Assign Values

# %%
set a 1
puts "a = $a"

# %% [markdown]
# # Loop

# %%
for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}

# %%
26 changes: 26 additions & 0 deletions tests/notebooks/mirror/ipynb_to_md/tcl_test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
jupyter:
kernelspec:
display_name: Tcl
language: tcl
name: tcljupyter
---

# Assign Values

```tcl
set a 1
puts "a = $a"
```

# Loop

```tcl
for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}
```

```tcl

```
25 changes: 25 additions & 0 deletions tests/notebooks/mirror/ipynb_to_myst/tcl_test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
kernelspec:
display_name: Tcl
language: tcl
name: tcljupyter
---

# Assign Values

```{code-cell}
set a 1
puts "a = $a"
```

# Loop

```{code-cell}
for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}
```

```{code-cell}

```
24 changes: 24 additions & 0 deletions tests/notebooks/mirror/ipynb_to_percent/tcl_test.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ---
# jupyter:
# kernelspec:
# display_name: Tcl
# language: tcl
# name: tcljupyter
# ---

# %% [markdown]
# # Assign Values

# %%
set a 1
puts "a = $a"

# %% [markdown]
# # Loop

# %%
for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}

# %%
20 changes: 20 additions & 0 deletions tests/notebooks/mirror/ipynb_to_script/tcl_test.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ---
# jupyter:
# kernelspec:
# display_name: Tcl
# language: tcl
# name: tcljupyter
# ---

# # Assign Values

set a 1
puts "a = $a"

# # Loop

for {set i 0} {$i < 10} {incr i} {
puts "I inside first loop: $i"
}