From dbdd97847f5e3a5c48eb559f9e1a4e62654e05fd Mon Sep 17 00:00:00 2001 From: Andrey Makarov Date: Wed, 7 Apr 2021 21:47:15 +0300 Subject: [PATCH] fix bug 17 from #17340 --- lib/packages/docutils/rst.nim | 3 ++- tests/stdlib/trstgen.nim | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index f220c416a2c98..a8bc04a1a510b 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -1752,7 +1752,8 @@ proc whichSection(p: RstParser): RstNodeKind = return rnCodeBlock elif currentTok(p).symbol == "::": return rnLiteralBlock - elif currentTok(p).symbol == ".." and predNL(p): + elif currentTok(p).symbol == ".." and predNL(p) and + nextTok(p).kind in {tkWhite, tkIndent}: return rnDirective case currentTok(p).kind of tkAdornment: diff --git a/tests/stdlib/trstgen.nim b/tests/stdlib/trstgen.nim index 0323cda149c69..b403d96c680da 100644 --- a/tests/stdlib/trstgen.nim +++ b/tests/stdlib/trstgen.nim @@ -151,6 +151,10 @@ suite "YAML syntax highlighting": check "(3, 25) Warning: RST style:" in warnings[1] check "RST style: too many colons for a directive (should be ::)" in warnings[1] + test "not a directive": + let input = "..warning:: I am not a warning." + check input.toHtml == input + test "Anchors, Aliases, Tags": let input = """.. code-block:: yaml --- !!map