From 93622da34e54fb6529bfb7c57e710f37a8d9cbd8 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sat, 16 Jul 2016 11:34:03 -0400 Subject: [PATCH] Make newline mandatory for opening fence line. (#281) 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. --- block.go | 2 +- block_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/block.go b/block.go index b237c7e..0b5510d 100644 --- a/block.go +++ b/block.go @@ -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 } diff --git a/block_test.go b/block_test.go index 6170e56..62d9a47 100644 --- a/block_test.go +++ b/block_test.go @@ -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,