diff --git a/org/inline.go b/org/inline.go index 02d5a15..09c58f1 100644 --- a/org/inline.go +++ b/org/inline.go @@ -147,8 +147,8 @@ func (d *Document) parseExplicitLineBreakOrLatexFragment(input string, start int switch { case start+2 >= len(input): case input[start+1] == '\\' && start != 0 && input[start-1] != '\n': - for i := start + 2; unicode.IsSpace(rune(input[i])); i++ { - if i >= len(input) || input[i] == '\n' { + for i := start + 2; i <= len(input)-1 && unicode.IsSpace(rune(input[i])); i++ { + if input[i] == '\n' { return i + 1 - start, ExplicitLineBreak{} } } diff --git a/org/testdata/misc.html b/org/testdata/misc.html index f8b2397..c209ccd 100644 --- a/org/testdata/misc.html +++ b/org/testdata/misc.html @@ -68,9 +68,11 @@ +
  • index out of range in explicit line break parsing +
  • -
  • Footnotes +
  • Footnotes
  • @@ -499,7 +501,13 @@ index out of range in headline priority parsing

    [#B

    -

    +

    +index out of range in explicit line break parsing +

    +

    +0\\ +

    +

    Footnotes

    diff --git a/org/testdata/misc.org b/org/testdata/misc.org index e8813a7..78d5dbc 100644 --- a/org/testdata/misc.org +++ b/org/testdata/misc.org @@ -136,6 +136,9 @@ When inserting an image link like [[/home/amos/Pictures/Screenshots/img-2017-09- ** misc fuzz / regression / edge case *** index out of range in headline priority parsing **** [#B +*** index out of range in explicit line break parsing +0\\ + * Footnotes [fn:1] a footnote /with/ *markup* diff --git a/org/testdata/misc.pretty_org b/org/testdata/misc.pretty_org index cc128a3..ff61450 100644 --- a/org/testdata/misc.pretty_org +++ b/org/testdata/misc.pretty_org @@ -136,6 +136,9 @@ When inserting an image link like [[/home/amos/Pictures/Screenshots/img-2017-09- ** misc fuzz / regression / edge case *** index out of range in headline priority parsing **** [#B +*** index out of range in explicit line break parsing +0\\ + * Footnotes [fn:1] a footnote /with/ *markup*