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

Don't throw errors on RST tables in Markdown and RstMarkdown modes #22165

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

a-mr
Copy link
Contributor

@a-mr a-mr commented Jun 27, 2023

Additions to RST simple tables (#19859) made their parsing more restrictive, which can introduce problems with of some old nimforum posts, which have tables with sloppily aligned columns (like this one:
nim-lang/nimforum#330 (comment)). Also this strictness contradicts to Markdown style of not getting in the way (ignoring errors).

So this PR proposes a new strategy of dealing with errors:

  • In Markdown and legacy (old default) RstMarkdown we try to continue parsing, emitting only warnings
  • And only in pure RST mode we throw a error

I expect that this strategy will be applied to more parts of markup code in the future.

Additions to RST simple tables (nim-lang#19859) made their parsing more
restrictive, which can introduce problems with of some old
nimforum posts, which have tables with sloppily aligned columns
(like this one:
nim-lang/nimforum#330 (comment)).
Also this strictness contradicts to Markdown style of not getting
in the way (ignoring errors).

So this PR proposes a new strategy of dealing with errors:
* In Markdown and legacy (old default) RstMarkdown we try to
  continue parsing, emitting only warnings
* And only in pure RST mode we throw a error

I expect that this strategy will be applied to more parts of markup code
in the future.
@@ -2593,14 +2616,14 @@ proc getColumns(p: RstParser, cols: var RstCols, startIdx: int): int =
if p.tok[result].kind != tkAdornment: break
if p.tok[result].kind == tkIndent: inc result

proc checkColumns(p: RstParser, cols: RstCols) =
proc checkColumns(p: RstParser, cols: RstCols): bool =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of always returning true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silly me. Wanted to abort parsing table in some cases, but then decided it's not worth it. Reverted.

@Araq Araq merged commit 57de460 into nim-lang:devel Jun 28, 2023
17 of 19 checks passed
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 57de460

Hint: mm: orc; opt: speed; options: -d:release
168109 lines; 8.183s; 612.203MiB peakmem

bung87 pushed a commit to bung87/Nim that referenced this pull request Jul 29, 2023
…im-lang#22165)

* Don't throw errors on RST tables in Markdown and RstMarkdown modes

Additions to RST simple tables (nim-lang#19859) made their parsing more
restrictive, which can introduce problems with of some old
nimforum posts, which have tables with sloppily aligned columns
(like this one:
nim-lang/nimforum#330 (comment)).
Also this strictness contradicts to Markdown style of not getting
in the way (ignoring errors).

So this PR proposes a new strategy of dealing with errors:
* In Markdown and legacy (old default) RstMarkdown we try to
  continue parsing, emitting only warnings
* And only in pure RST mode we throw a error

I expect that this strategy will be applied to more parts of markup code
in the future.

* Don't return anything in `checkColumns`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants