mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
fix a parsing issue with input that ends with non-whitespace characters
This commit is contained in:
parent
ea8789f650
commit
f6a84f0487
2 changed files with 12 additions and 3 deletions
|
|
@ -223,7 +223,7 @@ func parseLastLineAttributes(node ast.Node, reader text.Reader, pc Context) {
|
||||||
}
|
}
|
||||||
lr.Advance(1)
|
lr.Advance(1)
|
||||||
}
|
}
|
||||||
if ok && util.IsBlank(line[end.Stop:]) {
|
if ok && util.IsBlank(lr.Source()[end.Stop:]) {
|
||||||
for _, attr := range attrs {
|
for _, attr := range attrs {
|
||||||
node.SetAttribute(attr.Name, attr.Value)
|
node.SetAttribute(attr.Name, attr.Value)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package text
|
package text
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/yuin/goldmark/util"
|
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"github.com/yuin/goldmark/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
const invalidValue = -1
|
const invalidValue = -1
|
||||||
|
|
@ -83,9 +84,17 @@ type reader struct {
|
||||||
|
|
||||||
// NewReader return a new Reader that can read UTF-8 bytes .
|
// NewReader return a new Reader that can read UTF-8 bytes .
|
||||||
func NewReader(source []byte) Reader {
|
func NewReader(source []byte) Reader {
|
||||||
|
sourceLength := len(source)
|
||||||
|
if sourceLength > 0 {
|
||||||
|
if !util.IsSpace(source[sourceLength-1]) {
|
||||||
|
source = append(source, ' ')
|
||||||
|
sourceLength++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
r := &reader{
|
r := &reader{
|
||||||
source: source,
|
source: source,
|
||||||
sourceLength: len(source),
|
sourceLength: sourceLength,
|
||||||
}
|
}
|
||||||
r.ResetPosition()
|
r.ResetPosition()
|
||||||
return r
|
return r
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue