From 5147283a32a143615ea144d4c3c0d024cbb8209a Mon Sep 17 00:00:00 2001 From: Albert S Date: Mon, 26 Aug 2019 20:51:59 +0200 Subject: [PATCH] page view: fix messed up ul close tags --- handlers/handlerpageview.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/handlers/handlerpageview.cpp b/handlers/handlerpageview.cpp index 128f226..0a280b2 100644 --- a/handlers/handlerpageview.cpp +++ b/handlers/handlerpageview.cpp @@ -38,25 +38,32 @@ std::string HandlerPageView::createIndexContent(IParser &parser, std::string con { std::vector headlines = parser.extractHeadlines(content); std::string indexcontent = ""; - unsigned int l = 0; + unsigned int previous = 0; for(const Headline &h : headlines) { - if(h.level > l) + if(h.level > previous) { indexcontent += ""; + unsigned int diff = previous - h.level; + for(unsigned int i = 0; i < diff; i++) + { + indexcontent += ""; + } } - l = h.level; + previous = h.level; HtmlLink link; link.href="#" + h.title; link.innervalue = h.title; link.cssclass = "indexlink"; indexcontent += "
  • "+link.render()+"
  • "; } - indexcontent += ""; + for(unsigned int i = 0; i < previous; i++) + { + indexcontent += ""; + } return indexcontent; }