General Usage
After installing the package, any fenced code block with the language rst
will be converted to reStructuredText
by the rst-in-md
tool.
Basic Example
For example, this markdown:
```rst
.. table:: Truth table for "not"
:widths: auto
===== =====
A not A
===== =====
False True
True False
===== =====
```
Will be converted to this reStructuredText
:
A | not A |
---|---|
False | True |
True | False |
Note
This will work for any short names that are used for the reStructuredText
language identifier:
rst
restructuredtext
rest
For example, you can replace ```rst
with ```rest
or ```restructuredtext
You can also ignore specific code blocks if you want them rendered the normal way.
Supported Features
reStructuredText
is a powerful markup language that can be used to create a lot of complex structures. This includes directives like tables, images, etc. This also includes some latex math support, which can be used to render equations.
The rst-in-md
tool officially supports just a small subset of the features that reStructuredText
provides, since a lot of them are redundant when used within a Markdown document.
Below are some of the features that are supported.
Simple Tables
```rst
===== =====
A B
===== =====
False False
True False
False True
True True
===== =====
```
A | B |
---|---|
False | False |
True | False |
False | True |
True | True |
Grid Tables
```rst
+------------------------+------------+----------+----------+
| Header row, column 1 | Header 2 | Header 3 | Header 4 |
| (header rows optional) | | | |
+========================+============+==========+==========+
| body row 1, column 1 | column 2 | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2 | Cells may span columns. |
+------------------------+------------+---------------------+
| body row 3 | Cells may | - Table cells |
+------------------------+ span rows. | - contain |
| body row 4 | | - body elements. |
+------------------------+------------+---------------------+
```
Header row, column 1 (header rows optional) | Header 2 | Header 3 | Header 4 |
---|---|---|---|
body row 1, column 1 | column 2 | column 3 | column 4 |
body row 2 | Cells may span columns. | ||
body row 3 | Cells may span rows. |
|
|
body row 4 |
List Tables
```rst
.. list-table:: Title
:widths: 25 25 50
:header-rows: 1
* - Heading row 1, column 1
- Heading row 1, column 2
- Heading row 1, column 3
* - Row 1, column 1
-
- Row 1, column 3
* - Row 2, column 1
- Row 2, column 2
- Row 2, column 3
```
Heading row 1, column 1 | Heading row 1, column 2 | Heading row 1, column 3 |
---|---|---|
Row 1, column 1 | Row 1, column 3 | |
Row 2, column 1 | Row 2, column 2 | Row 2, column 3 |
Latex math support
```rst
.. math::
\int_{-\infty}^\infty e^{-x^2} dx = \sqrt{\pi}
```