page view: fix messed up ul close tags
This commit is contained in:
parent
116fe5aecc
commit
5147283a32
@ -38,25 +38,32 @@ std::string HandlerPageView::createIndexContent(IParser &parser, std::string con
|
|||||||
{
|
{
|
||||||
std::vector<Headline> headlines = parser.extractHeadlines(content);
|
std::vector<Headline> headlines = parser.extractHeadlines(content);
|
||||||
std::string indexcontent = "";
|
std::string indexcontent = "";
|
||||||
unsigned int l = 0;
|
unsigned int previous = 0;
|
||||||
for(const Headline &h : headlines)
|
for(const Headline &h : headlines)
|
||||||
{
|
{
|
||||||
if(h.level > l)
|
if(h.level > previous)
|
||||||
{
|
{
|
||||||
indexcontent += "<ul>";
|
indexcontent += "<ul>";
|
||||||
}
|
}
|
||||||
else if(h.level < l)
|
else if(h.level < previous)
|
||||||
|
{
|
||||||
|
unsigned int diff = previous - h.level;
|
||||||
|
for(unsigned int i = 0; i < diff; i++)
|
||||||
{
|
{
|
||||||
indexcontent += "</ul>";
|
indexcontent += "</ul>";
|
||||||
}
|
}
|
||||||
l = h.level;
|
}
|
||||||
|
previous = h.level;
|
||||||
HtmlLink link;
|
HtmlLink link;
|
||||||
link.href="#" + h.title;
|
link.href="#" + h.title;
|
||||||
link.innervalue = h.title;
|
link.innervalue = h.title;
|
||||||
link.cssclass = "indexlink";
|
link.cssclass = "indexlink";
|
||||||
indexcontent += "<li>"+link.render()+"</li>";
|
indexcontent += "<li>"+link.render()+"</li>";
|
||||||
}
|
}
|
||||||
|
for(unsigned int i = 0; i < previous; i++)
|
||||||
|
{
|
||||||
indexcontent += "</ul>";
|
indexcontent += "</ul>";
|
||||||
|
}
|
||||||
return indexcontent;
|
return indexcontent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user