Skip to content

Commit

Permalink
RST opt.list to have priority over def.list (nim-lang#17845)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mr authored and PMunch committed Mar 28, 2022
1 parent d2ba350 commit 339b781
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/packages/docutils/rst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1867,10 +1867,10 @@ proc whichSection(p: RstParser): RstNodeKind =
elif match(p, p.idx, "(e) ") or match(p, p.idx, "e) ") or
match(p, p.idx, "e. "):
result = rnEnumList
elif isDefList(p):
result = rnDefList
elif isOptionList(p):
result = rnOptionList
elif isDefList(p):
result = rnDefList
else:
result = rnParagraph
of tkWord, tkOther, tkWhite:
Expand Down
26 changes: 26 additions & 0 deletions tests/stdlib/trst.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
discard """
output: '''
[Suite] RST parsing
[Suite] RST indentation
[Suite] RST include directive
Expand Down Expand Up @@ -55,6 +57,30 @@ proc toAst(input: string,
except EParseError:
discard

suite "RST parsing":
test "option list has priority over definition list":
check(dedent"""
--defusages
file
-o set
""".toAst ==
dedent"""
rnOptionList
rnOptionListItem order=1
rnOptionGroup
rnLeaf '--'
rnLeaf 'defusages'
rnDescription
rnInner
rnLeaf 'file'
rnOptionListItem order=2
rnOptionGroup
rnLeaf '-'
rnLeaf 'o'
rnDescription
rnLeaf 'set'
""")

suite "RST indentation":
test "nested bullet lists":
let input = dedent """
Expand Down

0 comments on commit 339b781

Please sign in to comment.