Skip to content

Commit

Permalink
nested ul element should be inside the preceding li not in a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed May 11, 2013
1 parent 7aa886d commit e1d0924
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/groovy/markdown2book/Generator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -211,29 +211,27 @@ class Generator {
def sb = new StringBuilder()
sb << '<ul>'
final int currentLevel = toc[0].heading.level
boolean firstItem = true
boolean done = false
while (!done) {
while (!toc.empty && !done) {
def tocEntry = toc[0]
if (tocEntry.heading.level > currentLevel) {
sb << '<li>' << tocMarkup(toc, outputFileName) << '</li>'
sb << tocMarkup(toc, outputFileName)
} else if (tocEntry.heading.level == currentLevel) {
if (firstItem) firstItem = false
else sb << '</li>'
sb << '<li>'
sb << '<span class="toc_number">' << tocEntry.prefix << '</span>'
sb << '<a href="' << outputFileName << "#" << tocEntry.id << '">'
sb << tocEntry.heading.title
sb << '</a>'
sb << '</li>'

toc.remove(0)
} else {
done = true
}

if (toc.empty) {
done = true
}
}
sb << '</ul>'
sb << '</li></ul>'
sb.toString()
}

Expand Down

0 comments on commit e1d0924

Please sign in to comment.