Skip to content

RST minor bugs #17340

Open
Open
@a-mr

Description

@a-mr

Let us track minor bugs in our RST implementation here.

Details

[x] 1. prefix role syntax doesn't work. Only postfix syntax does.

See :subscript:`some text` and :code:`other text`

See `some text`:subscript: and `other text`:code:

image

Should be (rst2html.py):
image

When started at the 1st column it's not even parsed:

:subscript:`some text`

Error: ':' expected

[x] 2. directive default-role does not do anything

This does not make text subscript:

.. default-role:: subscript

See `some text`.

rst2html.py:
image

[x] 3. make code default role

This implies non-escaping backslashes between ` `.

Also we need to create a variable to track the default role in the first place :-)

[ ] 4. escape \ does not work as expected in references

(see also #17315 (comment))

HTML Element: <a>
-----------------

HTML Element: <b>
-----------------

HTML Element: <c>
-----------------

See `HTML Element: \<a>`_

This is not even parsed:

See `HTML Element: <b\> `_
See `HTML Element: <c>\ `_.

Error: '`' expected

[x] 5. indentation bugs: some elements don't work on the first line when nested

:field: #. Item1
        #. Item2

image

Should work (rst2html.py):
image

The same goes e.g. for bullet list as contents and admonitions as the container

Generally, indentation handling is not aligned/systematic in different body elements handlers.

[x] 6. directive include does not work if :literal: has indent < 3

E.g. indentation of :literal: is 2:

.. include:: grammar.txt
  :literal:

Then contents of grammar.txt are not included and literal: appears as a block quote.

[x] 7. simple tables with spanning cells are displayed wrongly

=====  =====  ======
   Inputs     Output
------------  ------
  A      B    A or B
=====  =====  ======
False  False  False
=====  =====  ======

image

Should be (rst2html.py):
image

[ ] 8. wrong line in footnote reference and substitution reference

Consider this 2 mistakes:

Check [2]_ and |vrsn|

.. [1] footnote

.. |version| replace:: 1.5

The error reported is for line 6, which is EOF.

Solution: preserve original line of the references.

The same problem will be relevant for smart links

[ ] 9. no warning if no empty line after or before directive

.. warning:: Unsuitable for benchmarking (but still better than `now`),
use `monotimes.getMonoTime` instead or `cpuTime`, depending on use cases.

Solution: report a warning like rst2html.py does:

(WARNING/2) Explicit markup ends without a blank line; unexpected unindent.

When there is no empty line before directive the spec does not require anything. It silently parses as a normal paragraph both in rst.nim and rst2html.py. But it can be really confusing, we have to add a warning for this case also.

Also directive requires a blank line after it:

Good:

.. code:: c

   int main

Bad:

.. code:: c
   int main

[x] 10. combining of bullet lists with option lists is sometimes broken

Consider an option list with more than 1 items and description on more than 1 lines. It's included into a bullet list.

* a
  -m   desc1
  -n   very long
       desc2
* b

The bullet list is broken.
image

Interesting, rst2html.py (v 0.14) is broken in another way: it complains about wrong indentation at desc2, the same option list without the bullet list parses OK.

[ ] 11. some valid field lists are not parsed

It is probable that presence of non-alphanumeric symbols breaks them:

:(empty):         current directory `.` is assumed (not with --replace)
:-:               read buffer once from stdin: pipe or terminal input;

[ ] 12. Markdown: \| inside a table cell should render as | not \|

\| outside a table cell should keep rendering as \| (as it already does since #17315)

13. Syntax for trailing whitespaces does not work

:literal:`hi \ `

[x] 14. backslash + backtick escape does not work at the end of interpreted text

If \` is right before closing backtick then it fails to parse:

Markdown syntax is `\`\`\`nim ... \`\`\``.

Error: '`' expected
Interestingly, adding characters makes it compile:

Markdown syntax is `\`\`\`nim ... \`\`\`x`.

[ ] 15. no warning when literal block has wrong indentation

* two immediate following underscores `__` are not allowed::

  letter ::= 'A'..'Z' | 'a'..'z' | '\x80'..'\xff'

image

rst2html.py gives a warning:
literalBlock.rst:3: (WARNING/2) Literal block expected; none found.

Nim silently ignores the mistake.

[x] 16. roles with valid refname symbols are not parsed

e.g. :c++: is not parsed:

`#include <stdio.h>`:c++:

UPDATE: c++ is not a valid name according to the spec, it's just that rst2html.py parses it. However, valid refnames are not recognized.

[x] 17. two dots without space after them are recognized as a comment

..note:: text...

disappears.

Found in #17671.

[x] 18. Only = should be allowed for borders in simple tables

Our implementation should not allow using - for borders in simple tables. It's against the spec and rst2html and Github don't parse such tables: https://github.com/nim-lang/Nim/blob/devel/doc/nep1.rst

[x] 19. Multi-line comments starting from line of .. not recognized

.. comment beginning
   continuation

image

[ ] 20. a blank line between options splits option list

e.g.

-a  desc1

-b  desc2

is parsed as 2 option lists.

[x] 21. code block with line indented after option disappears

.. code-block:: nim
   :number-lines: 35
   
    let a = 1

Line let a = 1 indented positively w.r.t. :number-lines: option and the whole code block just disappears.

[ ] 22. Markdown code blocks gobble up indentation on first line

```nim
  discard 1
  discard 2
```

image

May be related to #17314 .

[ ] 23. Markdown code blocks don't respect indentation rule

This

See code:

  ```
  some code
  ```

is displayed as

image

Note two spaces before some code and RST block quote quotation bar to the left of it.

https://spec.commonmark.org/0.29/#fenced-code-block

If the leading code fence is indented N spaces, then up to N spaces of indentation are removed from each line of the content (if present).

Probably RST block quote feature should be turned off in default nim mode for that to work.

[x] 24. Markdown links don't not allow balanced parentheses or escaped parentheses

  https://en.wikipedia.org/wiki/APL_(programming_language)

  [foo](https://en.wikipedia.org/wiki/APL_(programming_language))
  
  [foo](https://en.wikipedia.org/wiki/APL_\(programming_language\))
  
  [foo](https://en.wikipedia.org/wiki/APL_\(programming_language\))

According to the spec this should be allowed.

[ ] 25. docgen: multiple 1-level doc comments are glued without spacing

## Main text.

proc f*() = discard

## More text.

image

I would expect a blank line between "Main text" and "More text".

[ ] 26. Internal anchor cannot be set for enum.list/bullet list points

This is valid syntax for assigning an anchor to internal point of enumeration list or bullet list:

1. point1

   .. _lnk:
2. point2

Ref lnk_.

It works in rst2html.py but not in rst.nim.

[ ] 27. Text after 3rd backtick in code disappears

`proc `=destroy`[T](f: var Foo[T])`

image

Found in #19058

[ ] 28. Still incorrect handling of indentation when text is wrapped

.. Note:: #. a
   #. b

Current behavior:
image

Correct behavior by rst2html.py:
image

version

Nim 1.5.1, but all or almost all are applicable to stable versions.

cc @narimiran @timotheecour

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentation GenerationRelated to documentation generation (but not content).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions