Set LIST_ITEM_END_OF_LIST when list is at end of document. (#305)

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.
pull/309/head
Dmitri Shuralyov 2016-09-08 23:28:54 -07:00 committed by GitHub
parent 93622da34e
commit 35eb537633
1 changed files with 6 additions and 0 deletions

View File

@ -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