|
2 | 2 |
|
3 | 3 | import org.jsoup.Jsoup |
4 | 4 | import org.jsoup.nodes.Element |
5 | | -import org.jsoup.select.Elements |
6 | 5 | import kotlin.io.path.Path |
7 | 6 | import kotlin.io.path.readText |
8 | 7 | import kotlin.io.path.writeText |
@@ -31,6 +30,7 @@ fun main() { |
31 | 30 | "api900", |
32 | 31 | "api920", |
33 | 32 | "api940", |
| 33 | + "api950", |
34 | 34 | ).forEach { v -> |
35 | 35 | val input = rootPath.resolve(v).readText() |
36 | 36 | val output = processVersion(input) |
@@ -96,48 +96,3 @@ fun processVersion(input: String): String { |
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
99 | | - |
100 | | -fun buildGraph(children: Elements) { |
101 | | - val root = Element("h0") |
102 | | - val tree = mutableMapOf<Element, MutableList<Element>>(root to mutableListOf()) |
103 | | - val stack = ArrayDeque(listOf(root)) |
104 | | - |
105 | | - children.forEach { el -> |
106 | | - when (el.tagName()) { |
107 | | - "h1", "h2", "h3", "h4", "h5", "h6" -> { |
108 | | - stack.lastOrNull()?.let { last -> |
109 | | - when { |
110 | | - last.level == el.level -> { |
111 | | - stack.removeLast() |
112 | | - stack.add(el) |
113 | | - tree[el] = mutableListOf() |
114 | | - } |
115 | | - |
116 | | - last.level < el.level -> { |
117 | | - stack.add(el) |
118 | | - tree[el] = mutableListOf() |
119 | | - } |
120 | | - |
121 | | - last.level > el.level -> { |
122 | | - stack.removeLast() |
123 | | - stack.removeLast() |
124 | | - stack.add(el) |
125 | | - tree[el] = mutableListOf() |
126 | | - } |
127 | | - |
128 | | - else -> error("Unhandled case") |
129 | | - } |
130 | | - } ?: run { |
131 | | - tree[el] = mutableListOf() |
132 | | - stack.add(el) |
133 | | - } |
134 | | - } |
135 | | - |
136 | | - "p", "ul", "table", "hr", "pre", "ol", "blockquote" -> { |
137 | | - tree[stack.last()]!!.add(el) |
138 | | - } |
139 | | - |
140 | | - else -> println("Unknown tag: ${el.tagName()}") |
141 | | - } |
142 | | - } |
143 | | -} |
0 commit comments