Skip to content

Commit

Permalink
Issue #12 : dos style newline breaks fence code block
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed May 23, 2019
1 parent 9b1570b commit 7b1dd7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions parser/fcode_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ func (b *fencedCodeBlockParser) Open(parent ast.Node, reader text.Reader, pc Con
rest := line[i:]
left := util.TrimLeftSpaceLength(rest)
right := util.TrimRightSpaceLength(rest)
infoStart, infoStop := segment.Start+i+left, segment.Stop-right
value := rest[left : len(rest)-right]
if fenceChar == '`' && bytes.IndexByte(value, '`') > -1 {
return nil, NoChildren
} else if infoStart != infoStop {
info = ast.NewTextSegment(text.NewSegment(infoStart, infoStop))
if left < len(rest)-right {
infoStart, infoStop := segment.Start+i+left, segment.Stop-right
value := rest[left : len(rest)-right]
if fenceChar == '`' && bytes.IndexByte(value, '`') > -1 {
return nil, NoChildren
} else if infoStart != infoStop {
info = ast.NewTextSegment(text.NewSegment(infoStart, infoStop))
}
}
}
pc.Set(fencedCodeBlockInfoKey, &fenceData{fenceChar, findent, oFenceLength})
Expand Down
1 change: 1 addition & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func VisualizeSpaces(bs []byte) []byte {
bs = bytes.Replace(bs, []byte(" "), []byte("[SPACE]"), -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("\r"), []byte("[CR]\n"), -1)
return bs
}

Expand Down

0 comments on commit 7b1dd7b

Please sign in to comment.