Skip to content

Commit

Permalink
Fix option lists with additional indentation in Markdown (#21633)
Browse files Browse the repository at this point in the history
This is more Markdown-ish way to fix issue #21055, then PR #21625.
It does not enable RST definition lists, instead it makes
adding additional indentation (less than 4) right after a paragraph
be ignored, as it's done for all block elements in Markdown.
(In this case this tenet is applied to option lists that are not
part of CommonMark spec by themselves).
  • Loading branch information
a-mr authored Apr 11, 2023
1 parent 4c073cf commit 420b0c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/packages/docutils/rst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,9 @@ proc parseParagraph(p: var RstParser, result: PRstNode) =
result.addIfNotNil(parseLineBlock(p))
of rnMarkdownBlockQuote:
result.addIfNotNil(parseMarkdownBlockQuote(p))
else: break
else:
dec p.idx # allow subsequent block to be parsed as another section
break
else:
break
of tkPunct:
Expand Down
26 changes: 26 additions & 0 deletions tests/stdlib/trst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,32 @@ suite "RST parsing":
rnLeaf 'desc2'
""")

test "definition lists work correctly with additional indentation in Markdown":
check(dedent"""
Paragraph:
-c desc1
-b desc2
""".toAst() ==
dedent"""
rnInner
rnInner
rnLeaf 'Paragraph'
rnLeaf ':'
rnOptionList
rnOptionListItem order=1
rnOptionGroup
rnLeaf '-'
rnLeaf 'c'
rnDescription
rnLeaf 'desc1'
rnOptionListItem order=2
rnOptionGroup
rnLeaf '-'
rnLeaf 'b'
rnDescription
rnLeaf 'desc2'
""")

test "RST comment":
check(dedent"""
.. comment1
Expand Down

0 comments on commit 420b0c1

Please sign in to comment.