From a2a98f5bfbbb670c6bf0165a035f1c960c6ed749 Mon Sep 17 00:00:00 2001 From: Andrey Makarov Date: Sun, 25 Apr 2021 15:35:30 +0300 Subject: [PATCH] RST opt.list to have priority over def.list --- lib/packages/docutils/rst.nim | 4 ++-- tests/stdlib/trst.nim | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index cb65791ffb409..11c879f794cc6 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -1831,10 +1831,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: diff --git a/tests/stdlib/trst.nim b/tests/stdlib/trst.nim index 2398b92a81927..33e1add157451 100644 --- a/tests/stdlib/trst.nim +++ b/tests/stdlib/trst.nim @@ -1,6 +1,8 @@ discard """ output: ''' +[Suite] RST parsing + [Suite] RST indentation [Suite] RST include directive @@ -51,6 +53,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 """