Skip to content

Commit

Permalink
Adding full list of HTML entities; Consolidated getter function for t…
Browse files Browse the repository at this point in the history
…ext property in Entities enum
  • Loading branch information
severn-everett committed Jan 24, 2023
1 parent 3466e6f commit 6071705
Show file tree
Hide file tree
Showing 3 changed files with 4,174 additions and 132 deletions.
15 changes: 5 additions & 10 deletions buildSrc/src/main/kotlin/kotlinx/html/generate/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,14 @@ fun generate(packg: String, todir: String, jsdir: String) {
append("enum ")
clazz(Clazz(name = "Entities")) {
InputStreamReader("entities.txt".asResourceUrl().openStream()).useLines { lines ->
lines.filter { it.isNotEmpty() }.forEachIndexed { idx, ent ->
// Have to avoid "equals" due to it being an Enum function name
lines.filter { it.isNotEmpty() && it != "equals" }.forEachIndexed { idx, ent ->
if (idx > 0) {
append(",")
}
indent()
append(ent)
// Have to escape "in", as it's a Kotlin keyword
append(if (ent == "in") "`$ent`" else ent)
emptyLine()
}
}
Expand All @@ -277,14 +279,7 @@ fun generate(packg: String, todir: String, jsdir: String) {
variable(Var(name = "text", type = "String"))
appendln()
getter()
defineIs(StringBuilder().apply {
append("&".quote())
append(" + ")
receiverDot("this")
functionCall("toString", emptyList())
append(" + ")
append(";".quote())
})
defineIs("&\$this;".quote())
appendln()
}
}
Expand Down
Loading

0 comments on commit 6071705

Please sign in to comment.