-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix RST parsing when no indent after enum.item (fix #17249) #17257
fix RST parsing when no indent after enum.item (fix #17249) #17257
Conversation
Digging into line numbers reporting I observed that columns are also wrong but this time they are shifted by +1 (it was not clear because columns are much more often reported completely incorrectly because of more It's because Nim global error/warning reporting adds |
let's followup in timotheecour#638 for how to solve this aspect cleanly throughout nim compiler in followup work |
CI failure is unrelated. Test improvements will be done in a follow-up PR. |
aa74473
to
e13174c
Compare
let col = currentTok(p).col | ||
var w = 0 | ||
while w < wildcards.len: | ||
if match(p, p.idx, wildcards[w]): break | ||
inc w | ||
assert w < wildcards.len | ||
proc checkAfterNewline(p: RstParser, report: bool): bool = | ||
let j = tokenAfterNewline(p, start=p.idx+1) | ||
if p.tok[j].kind notin {tkIndent, tkEof} and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting there, it's almost perfect...
another regression:
1. hello 1
1. hello 2
foo 2
1. hello 3
foo 3
1. sub1
1. sub2
1. sub3
zook5
1. hello 4
1. hello 5
1. hello 6
zook6
1. hello 7
1. hello 8
1. hello 9
1. hello 10
separator
1. hello 11
1. hello 12
before PR
after PR
- sub3 gets displaced
- there shouldn't be an interruption in numbering form
1. hello 5
to1. hello 6
but this could potentially be addressed in future PR, wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything is working as expected here.
- sub3 is not displaced. It's just parsed as normal paragraph according to RST specification because there is zook5 without indent after it
- the same here: "1. hello 6" was parsed as a normal paragraph and zook6 became a block quote because it's indented by 1
And the warning is issued in both cases, so it looks ok to me.
rst2html.py does the same thing if you change 1
s to #
s.
Also note that presence of auto-numerator 1
does not mean that it's a real "markdown mode".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to implement also markdown-style enumeration list parsing because it's basically just relaxation of the RST kind. But it would be another task.
can you rebase against devel maybe? not sure if it relates to your PR https://dev.azure.com/nim-lang/255dfe86-e590-40bb-a8a2-3c0295ebdeb1/_apis/build/builds/14075/logs/38
(refs #3123 (comment)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, remaining points can be addressed in followup work
(closed/re-opened so that bugfix #17327 is included) |
…17895) * revive #16627 now that csources_v1 was merged * use dedent in rst.nim, refs #17257 (comment) * fix test and improve rendering of a rst warning
…ces_v1 (nim-lang#17895) * revive nim-lang#16627 now that csources_v1 was merged * use dedent in rst.nim, refs nim-lang#17257 (comment) * fix test and improve rendering of a rst warning
According to RST spec this fragment
should be parsed as normal paragraph, not an enum.list, because there is no necessary indentation on the second line.
This PR makes rst.nim handle it in compliance with the spec and also adds a warning with suggestions how to fix it. Original python rst does not emit any warning but I think it's necessary since this behavior confuses people that are used to Markdown.
cc @narimiran
EDIT(timotheecour) fix #17249 (needed to put in body otherwise this PR won't show up in the ref'd issue: the link in title isn't enough) /cc @a-mr