1 | initial version |

Since sagemath-9.2 (see ticket #28838), the command `sage -sws2rst`

was resurrected via a new pip-installable package sage-sws2rst. It can be installed in Sage 9.2 using `sage -i sage_sws2rst`

.

Below is an example of usage. First we download a sage worksheet (.sws) prepared for Sage Days 20 at CIRM (Marseille, 2010):

```
$ wget http://slabbe.org/Sage/2010-perpignan/CIRM_Tutorial_1.sws
$ ls
CIRM_Tutorial_1.sws
```

We translate the sws worksheet into a ReStructuredText syntax file (.rst) using sage -sws2rst. This creates also a directory of images:

```
$ sage -sws2rst CIRM_Tutorial_1.sws
Processing CIRM_Tutorial_1.sws
File at CIRM_Tutorial_1.rst
Image directory at CIRM_Tutorial_1_media
$ ls
CIRM_Tutorial_1_media CIRM_Tutorial_1.rst CIRM_Tutorial_1.sws
```

Then, we can check that it works properly by looking at the generated rst file. Alternatively, we can translate it to a basic html file using rst2html:

```
$ rst2html.py CIRM_Tutorial_1.rst CIRM_Tutorial_1.html
CIRM_Tutorial_1.rst:176: (WARNING/2) Explicit markup ends without a blank line; unexpected unindent.
CIRM_Tutorial_1.rst:334: (WARNING/2) Inline strong start-string without end-string.
```

As seen above, there are few warnings sometimes because the translation made by sws2rst is not 100% perfect, but most of it is okay:

```
$ firefox CIRM_Tutorial_1.html
```

Moreover, one can use the sage -rst2ipynb script (installed with `sage -i rst2ipynb`

+ you may need to install `pandoc`

on the system) to translate the rst file obtained above to a Jupyter notebook:

```
$ sage -rst2ipynb CIRM_Tutorial_1.rst CIRM_Tutorial_1.ipynb
```

One can check the result:

```
$ sage -n jupyter
```

(This answer was copy-pasted from the ReleaseTour of Sage-9.2)

2 | No.2 Revision |

Since sagemath-9.2 (see ticket #28838), the command `sage -sws2rst`

was resurrected via a new pip-installable package sage-sws2rst. It can be installed in Sage 9.2 using `sage -i sage_sws2rst`

.

Below is an example of usage. First we download a sage worksheet (.sws) prepared for Sage Days 20 at CIRM (Marseille, 2010):

```
$ wget http://slabbe.org/Sage/2010-perpignan/CIRM_Tutorial_1.sws
$ ls
CIRM_Tutorial_1.sws
```

We translate the sws worksheet into a ReStructuredText syntax file (.rst) using sage -sws2rst. This creates also a directory of images:

```
$ sage -sws2rst CIRM_Tutorial_1.sws
Processing CIRM_Tutorial_1.sws
File at CIRM_Tutorial_1.rst
Image directory at CIRM_Tutorial_1_media
$ ls
CIRM_Tutorial_1_media CIRM_Tutorial_1.rst CIRM_Tutorial_1.sws
```

Then, we can check that it works properly by looking at the generated rst file. Alternatively, we can translate it to a basic html file using rst2html:

```
$ rst2html.py CIRM_Tutorial_1.rst CIRM_Tutorial_1.html
CIRM_Tutorial_1.rst:176: (WARNING/2) Explicit markup ends without a blank line; unexpected unindent.
CIRM_Tutorial_1.rst:334: (WARNING/2) Inline strong start-string without end-string.
```

As seen above, there are few warnings sometimes because the translation made by sws2rst is not 100% perfect, but most of it is okay:

```
$ firefox CIRM_Tutorial_1.html
```

Moreover, one can use the sage -rst2ipynb script (installed with `sage -i rst2ipynb`

+ you may need to install `pandoc`

on the system) to translate the rst file obtained above to a Jupyter notebook:

```
$ sage -rst2ipynb CIRM_Tutorial_1.rst CIRM_Tutorial_1.ipynb
```

One can check the result:

```
$ sage -n jupyter
```

(This answer was copy-pasted from the ReleaseTour of Sage-9.2)

Note that to translate old .sws files to .ipynb, you may also use the export notebook:

```
$ sage -n -h
[...]
* List available legacy Sage notebooks:
sage --notebook=export --list
* Export a legacy Sage notebook as a Jupyter notebook:
sage --notebook=export --ipynb=Output.ipynb admin:10
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.