Skip to content

Commit

Permalink
Set LIST_ITEM_END_OF_LIST when list is at end of document. (#305)
Browse files Browse the repository at this point in the history
The LIST_ITEM_END_OF_LIST flag is an internal flag passed to renderers
when rendering list items. It's normally set for the last item in the
list.

This change fixes the issue where that flag wasn't set in situations
where the Markdown document ends with the list being the last block
level item in it.

The cases above detect and set LIST_ITEM_END_OF_LIST flag when the list
ends because another thing begins, but they miss it when the end of
document is reached.

No tests here because this subtle internal behavior is hard to test and
would require quite a bit of testing/mock infrastructure.

Helps shurcooL/markdownfmt#30.
  • Loading branch information
dmitshur authored Sep 9, 2016
1 parent 93622da commit 35eb537
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions block.go
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,12 @@ gatherlines:
line = i
}

// If reached end of data, the Renderer.ListItem call we're going to make below
// is definitely the last in the list.
if line >= len(data) {
*flags |= LIST_ITEM_END_OF_LIST
}

rawBytes := raw.Bytes()

// render the contents of the list item
Expand Down

0 comments on commit 35eb537

Please # to comment.