mirror of https://github.com/zedeus/nitter
notes: properly flush list
This commit is contained in:
parent
d648c9c037
commit
17a2e0f334
|
@ -103,16 +103,19 @@ proc renderNote*(article: Article; prefs: Prefs): VNode =
|
||||||
var listType = ArticleType.unknown
|
var listType = ArticleType.unknown
|
||||||
var list: VNode = nil
|
var list: VNode = nil
|
||||||
|
|
||||||
|
proc flushList() =
|
||||||
|
if list != nil:
|
||||||
|
main.add list
|
||||||
|
list = nil
|
||||||
|
listType = ArticleType.unknown
|
||||||
|
|
||||||
for paragraph in article.paragraphs:
|
for paragraph in article.paragraphs:
|
||||||
let node = renderNoteParagraph(paragraph, article)
|
let node = renderNoteParagraph(paragraph, article)
|
||||||
|
|
||||||
let currentType = paragraph.baseType
|
let currentType = paragraph.baseType
|
||||||
if currentType in [ArticleType.orderedListItem, ArticleType.unorderedListItem]:
|
if currentType in [ArticleType.orderedListItem, ArticleType.unorderedListItem]:
|
||||||
if currentType != listType:
|
if currentType != listType:
|
||||||
# flush last list
|
flushList()
|
||||||
if list != nil:
|
|
||||||
main.add list
|
|
||||||
list = nil
|
|
||||||
|
|
||||||
case currentType:
|
case currentType:
|
||||||
of ArticleType.orderedListItem:
|
of ArticleType.orderedListItem:
|
||||||
|
@ -123,10 +126,10 @@ proc renderNote*(article: Article; prefs: Prefs): VNode =
|
||||||
listType = currentType
|
listType = currentType
|
||||||
list.add node
|
list.add node
|
||||||
else:
|
else:
|
||||||
if list != nil:
|
flushList()
|
||||||
main.add list
|
|
||||||
list = nil
|
|
||||||
main.add node
|
main.add node
|
||||||
|
|
||||||
|
flushList()
|
||||||
|
|
||||||
buildHtml(tdiv(class="note")):
|
buildHtml(tdiv(class="note")):
|
||||||
img(class="cover", src=(cover), alt="")
|
img(class="cover", src=(cover), alt="")
|
||||||
|
|
Loading…
Reference in New Issue