Skip to content

Commit

Permalink
Make newline mandatory for opening fence line. (#281)
Browse files Browse the repository at this point in the history
This was an unintended typo/mistake in #280.

This is stricter, and it's fine. The opening fence line will always need to have a newline.

Add another test for isFenceLine.
  • Loading branch information
dmitshur authored Jul 16, 2016
1 parent 4e6f303 commit 93622da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion block.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ func isFenceLine(data []byte, syntax *string, oldmarker string, newlineOptional
// If doRender is true, a final newline is mandatory to recognize the fenced code block.
func (p *parser) fencedCodeBlock(out *bytes.Buffer, data []byte, doRender bool) int {
var syntax string
beg, marker := isFenceLine(data, &syntax, "", true)
beg, marker := isFenceLine(data, &syntax, "", false)
if beg == 0 || beg >= len(data) {
return 0
}
Expand Down
6 changes: 6 additions & 0 deletions block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,12 @@ func TestIsFenceLine(t *testing.T) {
wantEnd: 4,
wantMarker: "```",
},
{
data: []byte("```\nstuff here\n"),
syntaxRequested: true,
wantEnd: 4,
wantMarker: "```",
},
{
data: []byte("stuff here\n```\n"),
wantEnd: 0,
Expand Down

0 comments on commit 93622da

Please # to comment.