RST parser: fixes #8158

This commit is contained in:
Araq 2019-01-11 16:31:24 +01:00 • committed by Andreas Rumpf
commit 56b804a283
3 changed files with 20 additions and 4 deletions

View file

@ -560,9 +560,9 @@ proc match(p: RstParser, start: int, expr: string): bool =
result = (p.tok[j].kind == tkWord) or (p.tok[j].symbol == "#")
if result:
case p.tok[j].symbol[0]
of 'a'..'z', 'A'..'Z': result = len(p.tok[j].symbol) == 1
of 'a'..'z', 'A'..'Z', '#': result = len(p.tok[j].symbol) == 1
of '0'..'9': result = allCharsInSet(p.tok[j].symbol, {'0'..'9'})
else: discard
else: result = false
else:
var c = expr[i]
var length = 0
@ -1105,7 +1105,7 @@ proc whichSection(p: RstParser): RstNodeKind =
elif match(p, p.idx, ":w:") and predNL(p):
# (p.tok[p.idx].symbol == ":")
result = rnFieldList
elif match(p, p.idx, "(e) "):
elif match(p, p.idx, "(e) ") or match(p, p.idx, "e. "):
result = rnEnumList
elif match(p, p.idx, "+a+"):
result = rnGridTable

View file

@ -1281,7 +1281,14 @@ function main() {
<h2><a class="toc-backref" id="this-is-now-a-header-next-header" href="#this-is-now-a-header-next-header">Next header</a></h2>
<h3><a class="toc-backref" id="next-header-and-so-on" href="#next-header-and-so-on">And so on</a></h3>
<h1><a class="toc-backref" id="more-headers" href="#more-headers">More headers</a></h1>
<h6><a class="toc-backref" id="more-headers-up-to-level-6" href="#more-headers-up-to-level-6">Up to level 6</a></h6></p>
<h6><a class="toc-backref" id="more-headers-up-to-level-6" href="#more-headers-up-to-level-6">Up to level 6</a></h6><ol class="simple"><li>An enumeration</li>
<li>Second idea here.</li>
</ol>
<p>More text.</p>
<ol class="simple"><li>Other case value</li>
<li>Second case.</li>
</ol>
</p>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">

View file

@ -10,6 +10,15 @@
###### Up to level 6
#. An enumeration
#. Second idea here.
More text.
1. Other case value
2. Second case.
]##
type