properly ignore hunks that are not followed immediately by a code block
commit 5c5ae707f1a8cb74d3e0db5517cf5e3ba9ef6812 · parent 65b1ac1fa4
· browse this tree
Calvin Behling, 2022-12-01 20:13:28 UTC
diff --git a/read.go b/read.go index a45edc1..f92561f 100644 --- a/read.go +++ b/read.go @@ -86,6 +86,7 @@ func Parse(data []byte) (*Document, error) { // ... Log a complaint? I don't think halting with a parse error would be helpful. // But definitely don't wait around for arbitrarily distant code blocks. expectCodeBlock = false + hunkInProgress = DocHunk{LineStart: -1} } // Look for testmark block indicators. if bytes.HasPrefix(line, sigilTestmark) { diff --git a/read_test.go b/read_test.go index 8c6946f..a6ab320 100644 --- a/read_test.go +++ b/read_test.go @@ -94,8 +94,11 @@ func TestParseTrailingExtraLineBreak(t *testing.T) { if err != nil { t.Fatal(err) } - hunk := doc.HunksByName["extra/newline"] - assert(t, hunk.Body, "foo\n") + hunk, exists := doc.HunksByName["extra/newline"] + if exists { + t.Errorf("testmark should ignore these") + } + assert(t, hunk.Body, "") } func TestDuplicateHunk(t *testing.T) {