Adds rst cheatsheet.

This commit is contained in:
Dominik Picheta 2018-05-24 14:43:18 +01:00
commit 2e3f8d4235
4 changed files with 71 additions and 81 deletions

View file

@ -349,7 +349,7 @@ $threads-meta-color: #545d70;
} }
} }
.post-content { .post-content, .about {
img { img {
max-width: 100%; max-width: 100%;
} }

View file

@ -1,5 +1,5 @@
reStructuredText cheat sheet Markdown and RST supported by this forum
=========================================================================== ========================================
This is a cheat sheet for the *reStructuredText* dialect as implemented by This is a cheat sheet for the *reStructuredText* dialect as implemented by
Nim's documentation generator which has been reused for this forum. Nim's documentation generator which has been reused for this forum.
@ -11,7 +11,6 @@ for further information.
Elements of **markdown** are also supported. Elements of **markdown** are also supported.
Inline elements Inline elements
--------------- ---------------
@ -28,6 +27,18 @@ Plain text Result
``\\escape`` \\escape ``\\escape`` \\escape
=============================== ============================================ =============================== ============================================
Quoting other users can be done by prefixing their message with ``>``::
> Hello World
Hi!
Which will result in:
> Hello World
Hi!
Links Links
----- -----
@ -44,33 +55,22 @@ Or like this::
Code blocks Code blocks
----------- -----------
are done this way:: The code blocks can be written in the same style as most common Markdown
flavours::
```nim
if x == "abc":
echo "xyz"
```
or using RST syntax::
.. code-block:: nim .. code-block:: nim
if x == "abc": if x == "abc":
echo "xyz" echo "xyz"
Both are rendered as:
Is rendered as:
.. code-block:: nim
if x == "abc":
echo "xyz"
Except Nim, the programming languages C, C++, Java and C# have highlighting
support.
An alternative github-like syntax is also supported. This has the advantage
that no excessive indentation is needed::
```nim
if x == "abc":
echo "xyz"```
Is rendered as:
.. code-block:: nim .. code-block:: nim
@ -78,18 +78,20 @@ Is rendered as:
echo "xyz" echo "xyz"
Apart from Nim, the programming languages C, C++, Java and C# also
have highlighting support.
Literal blocks Literal blocks
-------------- --------------
Are introduced by '::' and a newline. The block is indicated by indentation: These are introduced by '::' and a newline. The block is indicated by indentation:
:: ::
:: ::
if x == "abc": if x == "abc":
echo "xyz" echo "xyz"
Is rendered as:: The above is rendered as::
if x == "abc": if x == "abc":
echo "xyz" echo "xyz"
@ -99,7 +101,7 @@ Is rendered as::
Bullet lists Bullet lists
------------ ------------
look like this:: Bullet lists look like this::
* Item 1 * Item 1
* Item 2 that * Item 2 that
@ -110,7 +112,7 @@ look like this::
- item 3b - item 3b
- valid bullet characters are ``+``, ``*`` and ``-`` - valid bullet characters are ``+``, ``*`` and ``-``
Is rendered as: The above rendered as:
* Item 1 * Item 1
* Item 2 that * Item 2 that
spans over multiple lines spans over multiple lines
@ -124,7 +126,7 @@ Is rendered as:
Enumerated lists Enumerated lists
---------------- ----------------
are written like this:: Enumerated lists are written like this::
1. This is the first item 1. This is the first item
2. This is the second item 2. This is the second item
@ -132,60 +134,13 @@ are written like this::
single letters, or roman numerals single letters, or roman numerals
#. This item is auto-enumerated #. This item is auto-enumerated
Is rendered as: They are rendered as:
1. This is the first item 1. This is the first item
2. This is the second item 2. This is the second item
3. Enumerators are arabic numbers, 3. Enumerators are arabic numbers,
single letters, or roman numerals single letters, or roman numerals
#. This item is auto-enumerated #. This item is auto-enumerated
Quoting someone
---------------
quotes are just::
**Someone said**: Indented paragraphs,
and they may nest.
Is rendered as:
**Someone said**: Indented paragraphs,
and they may nest.
Definition lists
----------------
are written like this::
what
Definition lists associate a term with
a definition.
how
The term is a one-line phrase, and the
definition is one or more paragraphs or
body elements, indented relative to the
term. Blank lines are not allowed
between term and definition.
and look like:
what
Definition lists associate a term with
a definition.
how
The term is a one-line phrase, and the
definition is one or more paragraphs or
body elements, indented relative to the
term. Blank lines are not allowed
between term and definition.
Tables Tables
@ -221,6 +176,35 @@ Cell 7 Cell 8 Cell 9
Images Images
------ ------
Image embedding is supported. This includes GIFs as well as mp4 (for which a
<video> tag will be automatically generated).
For example:
``` ```
.. image:: path/to/img.png .. image:: https://upload.wikimedia.org/wikipedia/commons/6/69/Dog_morphological_variation.png
``` ```
Will render as:
.. image:: https://upload.wikimedia.org/wikipedia/commons/6/69/Dog_morphological_variation.png
And a GIF example:
```
.. image:: https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif
```
Will render as:
.. image:: https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif
You can also specify the size of the image:
```
.. image:: https://upload.wikimedia.org/wikipedia/commons/6/69/Dog_morphological_variation.png
:width: 40%
```
.. image:: https://upload.wikimedia.org/wikipedia/commons/6/69/Dog_morphological_variation.png
:width: 40%

View file

@ -1410,6 +1410,10 @@ routes:
}.newStringTable() }.newStringTable()
resp content.rstToHtml() resp content.rstToHtml()
get "/about/rst.html":
let content = readFile("public/rst.rst")
resp content.rstToHtml()
get "/threadActivity.xml": get "/threadActivity.xml":
createTFD() createTFD()
resp genThreadsRSS(c), "application/atom+xml" resp genThreadsRSS(c), "application/atom+xml"

View file

@ -118,6 +118,8 @@ when defined(js):
onChange=(e: Event, n: VNode) => onChange=(e: Event, n: VNode) =>
onChange(e, n, state), onChange(e, n, state),
value=state.text) value=state.text)
a(href=makeUri("/about/rst"), target="blank_"):
text "Styling with RST is supported"
if state.error.isSome(): if state.error.isSome():
span(class="text-error", span(class="text-error",