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

rst parser makes a line starting with > silently disappear #17987

Closed
timotheecour opened this issue May 10, 2021 · 9 comments · Fixed by #19147
Closed

rst parser makes a line starting with > silently disappear #17987

timotheecour opened this issue May 10, 2021 · 9 comments · Fixed by #19147
Labels
Documentation Generation Related to documentation generation (but not content). Severe

Comments

@timotheecour
Copy link
Member

timotheecour commented May 10, 2021

Last time i reported a bug in nimforum it turns out its root cause was nim's rst parser so I'm filing it here.

Example 1

see https://forum.nim-lang.org/t/7953#50676; i posted something like this:

foo https://github.com/nim-lang/Nim/issues/8258

> bar

Current Output

the 2nd line disappears

Expected Output

the 2nd line shouldn't be omitted, or at least it should give an error

Example 2

it works if there's something afterwards: this doesn't omit anything:

foo https://github.com/nim-lang/Nim/issues/8258

> bar

baz

Additional Information

1.5.1 72d6b59
/cc @a-mr

@timotheecour timotheecour added the Documentation Generation Related to documentation generation (but not content). label May 10, 2021
@timotheecour timotheecour changed the title rst parser makes a line with > silently disappear rst parser makes a line starting with > silently disappear May 10, 2021
@Araq Araq added the Severe label May 10, 2021
@a-mr
Copy link
Contributor

a-mr commented May 14, 2021

rst.nim does not support > quotes currently. It's nimforum code, see https://github.com/nim-lang/nimforum/blob/35e0de7b91fc76230574b2882005d1eccd12e2ad/src/utils.nim#L97

I think we need to support > quotes properly in rst.nim, so that nimforum could drop its own implementation. So we can keep this issue as a feature request.

@timotheecour
Copy link
Member Author

looks like > is indeed in both rst spec and markdown spec, and is a commonly used feature, so it's a good idea to support indeed:

rst: https://docutils.sourceforge.io/docs/user/rst/quickref.html

Per-line quoting can also be used on
unindented literal blocks::

> Useful for quotes from email and
> for Haskell literate programming.

markdown: https://wordpress.com/support/markdown-quick-reference/

> Quoted text.
> > Quoted quote.

> * Quoted 
> * List

is the 2nd example (with deeper nesting) also valid rst?

@a-mr
Copy link
Contributor

a-mr commented May 14, 2021

is the 2nd example (with deeper nesting) also valid rst?

nope, it requires :: before it.

But now the general direction is to move to better Markdown compatibility anyway (according to discussion in #17827) so I'm going to do it according to the Markdown style.

@timotheecour
Copy link
Member Author

can you give a quick summary of:

  • what's already valid
  • what will become valid
  • what will stay invalid?
    (and whether this is for both nim rst and nim doc or just one of these)
    btw is nimforum based on nim's support for rst or nim's support for nim doc ?

i think the most common/useful things to start with are:

not quoted
> 1st level quote
>> 2nd level quote
  • is an empty line required anywhere in the above snippet ?

@a-mr
Copy link
Contributor

a-mr commented May 14, 2021

  • nothing is valid, it's parsed just as normal text containing >
  • ideally both RST and Markdown style will become valid, but minimum target is Markdown style
  • nim doc and rst2html use the same parser and generator so it will be supported everywhere of course. nimforum uses helper rstgen.rstToHtml which is mostly trivial (FWIW it's not used in nim doc or rst2html). Basically it's all the same
  • in Markdown style a blank line would not be required, I suppose.

@a-mr
Copy link
Contributor

a-mr commented May 14, 2021

... I mean when roPreferMarkdown is set (which is currently default and cannot be changed) then blank line would not be required.

Because there will be more Markdown support, I'm thinking about providing an option like --pedantic or --pureRst to enforce pure RST-compliant behavior (in rst2html and probably doc), WDYT?

@timotheecour
Copy link
Member Author

timotheecour commented May 14, 2021

  • --pedantic is too vague, not self-documenting
  • --pureRst is better, but I much prefer enum-style flags, they're more naturally extensible/future proof/self-documenting, hence the move from --listfullpaths to --filenames:abs|canonical|legacyRelProj, --processing:dots|filenames|off for eg.

so I'd recommend: --docLang:nim|markdown|rst, which would default to --docLang:nim (nim's own mix of rst + markdown), whereas markdown would be pure markdown, rst pure rst.

this flag would compose and be honored by nim doc|rst2html|doc2rst

Also, --docLang starts with doc, like --docCmd, --docSeeSrcUrl, --docInternal, --docRoot, which makes it more discoverable.

(and ideally we can add aliases in future work for other doc-specific commands like --project, --index, but that's a separate topic)

@Araq
Copy link
Member

Araq commented May 15, 2021

so I'd recommend: --docLang:nim|markdown|rst, which would default to --docLang:nim (nim's own mix of rst + markdown), whereas markdown would be pure markdown, rst pure rst.

And then these flags end up in somebody's config causing subtle changes in the doc rendering pipeline. Or actually introducing more Nim dialects if we want to be picky. Nim is not about choices via the command line, if Nim offers choices, it should be done as language mechanisms. This is why we're moving from --gc:X to --gc:orc, not because Orc is the best GC, but because it works well with destructors and custom memory management so that we get an ecosystem of libraries that work well together.

Even a module specific "doclang" pragma would be preferable over a command line switch, command line switches don't compose.

@timotheecour
Copy link
Member Author

i agree with your points regarding fact that this shouldn't be a cmdline flag;

Even a module specific "doclang" pragma would be preferable over a command line switch

that's pretty much what I had proposed a while back in nim-lang/RFCs#68: {.doctype: markdown|rst.} to help with migration on a module-by-module basis

a-mr added a commit to a-mr/Nim that referenced this issue Aug 20, 2022
Implements nim-lang/RFCs#68 ,
see also discussion in nim-lang#17987

The permitted values:
* `markdown`, which is default. It still contains nearly all of
  the RST supported but it is assumed that in time we will give up
  most or all RST features in this mode
* `rst`, without any extensions
* `RstMarkdown` — compatibility with Nim 1.x. It's basically RST
  with those Markdown features enabled that don't conflict with RST.
Varriount added a commit that referenced this issue Aug 23, 2022
* Add `doctype: RST|Markdown|RstMarkdown` pragma

Implements nim-lang/RFCs#68 ,
see also discussion in #17987

The permitted values:
* `markdown`, which is default. It still contains nearly all of
  the RST supported but it is assumed that in time we will give up
  most or all RST features in this mode
* `rst`, without any extensions
* `RstMarkdown` — compatibility with Nim 1.x. It's basically RST
  with those Markdown features enabled that don't conflict with RST.

* Apply suggestions from code review

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Additional fix in spirit of review

* Fix test after #20188

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
* Add `doctype: RST|Markdown|RstMarkdown` pragma

Implements nim-lang/RFCs#68 ,
see also discussion in nim-lang#17987

The permitted values:
* `markdown`, which is default. It still contains nearly all of
  the RST supported but it is assumed that in time we will give up
  most or all RST features in this mode
* `rst`, without any extensions
* `RstMarkdown` — compatibility with Nim 1.x. It's basically RST
  with those Markdown features enabled that don't conflict with RST.

* Apply suggestions from code review

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>

* Additional fix in spirit of review

* Fix test after nim-lang#20188

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Generation Related to documentation generation (but not content). Severe
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants