diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-09-18 23:35:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-18 17:35:46 +0200 |
commit | c759d7abd1b4181fb4931bc95148beac3051bf91 (patch) | |
tree | c633d5c62fcb41d0f690fc24740f51f362184ca9 | |
parent | 04ccd2f4f07a169a03db3cc6f9316628c03f214a (diff) | |
download | Nim-c759d7abd1b4181fb4931bc95148beac3051bf91.tar.gz |
fixes rst parsing Markdown CodeblockFields blocking the loop (#24128)
```nim import packages/docutils/[rst, rstgen] let message = """```llvm-profdata""" echo rstgen.rstToHtml(message, {roSupportMarkdown}, nil) ```
-rw-r--r-- | lib/packages/docutils/rst.nim | 2 | ||||
-rw-r--r-- | tests/stdlib/trst.nim | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index a51ee49a6..706c50689 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -1526,7 +1526,7 @@ proc parseMarkdownCodeblockFields(p: var RstParser): PRstNode = result = nil else: result = newRstNode(rnFieldList) - while currentTok(p).kind != tkIndent: + while currentTok(p).kind notin {tkIndent, tkEof}: if currentTok(p).kind == tkWhite: inc p.idx else: diff --git a/tests/stdlib/trst.nim b/tests/stdlib/trst.nim index 2a7f0d3a4..ceab34bc9 100644 --- a/tests/stdlib/trst.nim +++ b/tests/stdlib/trst.nim @@ -16,6 +16,8 @@ discard """ [Suite] RST escaping [Suite] RST inline markup + +[Suite] Misc isssues ''' matrix: "--mm:refc; --mm:orc" """ @@ -1980,3 +1982,13 @@ suite "RST inline markup": rnLeaf ')' """) check(warnings[] == @["input(1, 5) Warning: broken link 'f'"]) + +suite "Misc isssues": + test "Markdown CodeblockFields in one line (lacking enclosing ```)": + let message = """ + ```llvm-profdata merge first.profraw second.profraw third.profraw <more stuff maybe> -output data.profdata```""" + + try: + echo rstgen.rstToHtml(message, {roSupportMarkdown}, nil) + except EParseError: + discard |