Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyVivedus committed Dec 4, 2024
1 parent d03b890 commit 2a0b5a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion parser/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,12 @@ func (p *Parser) fencedCodeBlock(data []byte, doRender bool) int {

// did we reach the end of the buffer without a closing marker?
if end >= len(data) {
return 0
if doRender {
// process the rest of the data as part of the code block
work.Write(data[beg:])
}
beg = len(data)
break
}

// verbatim copy to the working buffer
Expand Down
9 changes: 9 additions & 0 deletions parser/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,12 @@ func TestRect(t *testing.T) {
input, exp, got)
}
}

func TestInfiniteLoopFix(t *testing.T) {
input := "```\n: "
p := NewWithExtensions(CommonExtensions)
doc := p.Parse([]byte(input))
if doc == nil {
t.Errorf("Expected non-nil AST")
}
}

2 comments on commit 2a0b5a2

@kjk
Copy link

@kjk kjk commented on 2a0b5a2 Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I made a change inspired by your fix at gomarkdown@87d094f

Thanks for looking into it

@GuyVivedus
Copy link
Owner Author

@GuyVivedus GuyVivedus commented on 2a0b5a2 Dec 4, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.