Fix invalid handling of consecutive code spans

This commit is contained in:
yuin 2019-12-02 17:13:37 +09:00
parent 68dcec6ac4
commit ac8e225cd3
2 changed files with 17 additions and 1 deletions

View file

@ -8,6 +8,9 @@
B</li> B</li>
</ul> </ul>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
2 2
//- - - - - - - - -// //- - - - - - - - -//
**test**\ **test**\
@ -20,6 +23,9 @@ test<strong>test</strong><br />
<strong>test</strong>test<br /> <strong>test</strong>test<br />
test<strong>test</strong></p> test<strong>test</strong></p>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
3 3
//- - - - - - - - -// //- - - - - - - - -//
>* > >* >
@ -39,3 +45,13 @@ test<strong>test</strong></p>
3</p> 3</p>
</blockquote> </blockquote>
//= = = = = = = = = = = = = = = = = = = = = = = =// //= = = = = = = = = = = = = = = = = = = = = = = =//
4
//- - - - - - - - -//
`test`a`test`
//- - - - - - - - -//
<p><code>test</code>a<code>test</code></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -42,7 +42,7 @@ func (s *codeSpanParser) Parse(parent ast.Node, block text.Reader, pc Context) a
for ; i < len(line) && line[i] == '`'; i++ { for ; i < len(line) && line[i] == '`'; i++ {
} }
closure := i - oldi closure := i - oldi
if closure == opener && (i+1 >= len(line) || line[i+1] != '`') { if closure == opener && (i >= len(line) || line[i] != '`') {
segment = segment.WithStop(segment.Start + i - closure) segment = segment.WithStop(segment.Start + i - closure)
if !segment.IsEmpty() { if !segment.IsEmpty() {
node.AppendChild(node, ast.NewRawTextSegment(segment)) node.AppendChild(node, ast.NewRawTextSegment(segment))