import com.google.common.hash.Hashing
import com.google.common.io.Files
import org.jsoup.Jsoup
+import org.jsoup.nodes.Element
buildscript {
repositories {
return output
}
+def ulToList(Element ul, int indent) {
+ def list = ""
+ ul.children().each { e ->
+ if (e.tagName().toLowerCase() == "ul") {
+ list += "\n"
+ list += ulToList(e, indent+1)
+ } else if (e.tagName().toLowerCase() == "li") {
+ def issues = []
+ def mdItem = " " * indent + "- "
+ e.childNodes().any {n ->
+ if (n.nodeName().equals("#comment")) {
+ mdItem += "${n} "
+ issues = n.getData().trim().split(/[,\s]+/)
+ return true
+ }
+ }
+ def issuesLink = (issues.size() > 0) ?
+ " {{< jal issue=\"${issues.join(",")}\" >}}"
+ : ""
+ def addedIssues = false
+ e.childNodes().each { node ->
+ if (node.nodeName().toLowerCase() == "ul") {
+ // add issues link before sub list
+ mdItem += "${issuesLink}\n"
+ addedIssues = true
+ mdItem += ulToList(e, indent+1)
+ } else if (node.nodeName() == "#text") {
+ mdItem += node.text()
+ }
+ }
+ if (!addedIssues) {
+ mdItem += issuesLink
+ }
+ list += "${mdItem}\n"
+ }
+ }
+ return list
+}
+
task hugoTemplates {
group "website"
description "Create partially populated md pages for hugo website build"
def noheadings = true
releaseCells[col].children().each { e ->
if (e.tagName().toLowerCase() == "ul") {
- e.select("li").each { li ->
- def issues = []
- def mdItem = "- "
- li.childNodes().any {n ->
- if (n.nodeName().equals("#comment")) {
- mdItem += "${n} "
- issues = n.getData().trim().split(/[,\s]+/)
- return true
- }
- }
- mdItem += li.text()
- issues.each { jal ->
- mdItem += " {{< jal issue=\"${jal}\" >}}"
- }
- if (noheadings) {
- changes += "\n### ${headings[1]}\n\n"
- noheadings = false
- }
- changes += "${mdItem}\n"
+ def list = ulToList(e, 0)
+ if (noheadings && list != "") {
+ changes += "\n### ${headings[col]}\n\n"
+ noheadings = false
}
- } else if (e.tag() == "em") {
+ changes += list
+ } else if (e.tagName().toLowerCase() == "em") {
changes += "\n#### ${e.text()}\n\n"
noheadings = false
}
}
}
+
}
}
}