mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Issue #12 : dos style newline breaks fence code block
This commit is contained in:
parent
9b1570bcde
commit
7b1dd7b221
2 changed files with 9 additions and 6 deletions
|
|
@ -47,12 +47,14 @@ func (b *fencedCodeBlockParser) Open(parent ast.Node, reader text.Reader, pc Con
|
||||||
rest := line[i:]
|
rest := line[i:]
|
||||||
left := util.TrimLeftSpaceLength(rest)
|
left := util.TrimLeftSpaceLength(rest)
|
||||||
right := util.TrimRightSpaceLength(rest)
|
right := util.TrimRightSpaceLength(rest)
|
||||||
infoStart, infoStop := segment.Start+i+left, segment.Stop-right
|
if left < len(rest)-right {
|
||||||
value := rest[left : len(rest)-right]
|
infoStart, infoStop := segment.Start+i+left, segment.Stop-right
|
||||||
if fenceChar == '`' && bytes.IndexByte(value, '`') > -1 {
|
value := rest[left : len(rest)-right]
|
||||||
return nil, NoChildren
|
if fenceChar == '`' && bytes.IndexByte(value, '`') > -1 {
|
||||||
} else if infoStart != infoStop {
|
return nil, NoChildren
|
||||||
info = ast.NewTextSegment(text.NewSegment(infoStart, infoStop))
|
} else if infoStart != infoStop {
|
||||||
|
info = ast.NewTextSegment(text.NewSegment(infoStart, infoStop))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pc.Set(fencedCodeBlockInfoKey, &fenceData{fenceChar, findent, oFenceLength})
|
pc.Set(fencedCodeBlockInfoKey, &fenceData{fenceChar, findent, oFenceLength})
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@ func VisualizeSpaces(bs []byte) []byte {
|
||||||
bs = bytes.Replace(bs, []byte(" "), []byte("[SPACE]"), -1)
|
bs = bytes.Replace(bs, []byte(" "), []byte("[SPACE]"), -1)
|
||||||
bs = bytes.Replace(bs, []byte("\t"), []byte("[TAB]"), -1)
|
bs = bytes.Replace(bs, []byte("\t"), []byte("[TAB]"), -1)
|
||||||
bs = bytes.Replace(bs, []byte("\n"), []byte("[NEWLINE]\n"), -1)
|
bs = bytes.Replace(bs, []byte("\n"), []byte("[NEWLINE]\n"), -1)
|
||||||
|
bs = bytes.Replace(bs, []byte("\r"), []byte("[CR]\n"), -1)
|
||||||
return bs
|
return bs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue