Fix explicit line break parsing
It's possible for the input to end right after the explicit line break, i.e. after the second \. This currently leads to an out of range index into input (as the for loop starts with start+2 and [start:start+1] is the \\).
This commit is contained in:
parent
00d5a9cdd2
commit
da99094e20
4 changed files with 7 additions and 4 deletions
|
@ -129,7 +129,7 @@ func (d *Document) parseLineBreak(input string, start int) (int, Node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Document) parseExplicitLineBreak(input string, start int) (int, Node) {
|
func (d *Document) parseExplicitLineBreak(input string, start int) (int, Node) {
|
||||||
if start == 0 || input[start-1] == '\n' || start+1 >= len(input) || input[start+1] != '\\' {
|
if start == 0 || input[start-1] == '\n' || start+2 >= len(input) || input[start+1] != '\\' {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
for i := start + 2; unicode.IsSpace(rune(input[i])); i++ {
|
for i := start + 2; unicode.IsSpace(rune(input[i])); i++ {
|
||||||
|
|
3
org/testdata/inline.html
vendored
3
org/testdata/inline.html
vendored
|
@ -2,7 +2,8 @@
|
||||||
<li>
|
<li>
|
||||||
<p>
|
<p>
|
||||||
<em>emphasis</em> and a hard line break <br>
|
<em>emphasis</em> and a hard line break <br>
|
||||||
see?
|
see? <br>
|
||||||
|
also hard line breaks not followed by a newline get ignored, see \\
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
3
org/testdata/inline.org
vendored
3
org/testdata/inline.org
vendored
|
@ -1,5 +1,6 @@
|
||||||
- /emphasis/ and a hard line break \\
|
- /emphasis/ and a hard line break \\
|
||||||
see?
|
see? \\
|
||||||
|
also hard line breaks not followed by a newline get ignored, see \\
|
||||||
- /.emphasis with dot border chars./
|
- /.emphasis with dot border chars./
|
||||||
- /emphasis with a slash/inside/
|
- /emphasis with a slash/inside/
|
||||||
- /emphasis/ followed by raw text with slash /
|
- /emphasis/ followed by raw text with slash /
|
||||||
|
|
3
org/testdata/inline.pretty_org
vendored
3
org/testdata/inline.pretty_org
vendored
|
@ -1,5 +1,6 @@
|
||||||
- /emphasis/ and a hard line break \\
|
- /emphasis/ and a hard line break \\
|
||||||
see?
|
see? \\
|
||||||
|
also hard line breaks not followed by a newline get ignored, see \\
|
||||||
- /.emphasis with dot border chars./
|
- /.emphasis with dot border chars./
|
||||||
- /emphasis with a slash/inside/
|
- /emphasis with a slash/inside/
|
||||||
- /emphasis/ followed by raw text with slash /
|
- /emphasis/ followed by raw text with slash /
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue