Skip to content

Commit 366091c

Browse files
committed
preserve case for tags and attributes.
1 parent f0a49dc commit 366091c

File tree

3 files changed

+24
-49
lines changed

3 files changed

+24
-49
lines changed

converter/src/main/kotlin/de/jensklingenberg/htmltocfw/converter/Main.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package de.jensklingenberg.htmltocfw.converter
22

33
import de.jensklingenberg.htmltocfw.converter.node.getMyNode
44
import org.jsoup.Jsoup
5+
import org.jsoup.parser.Parser
56
import java.io.File
67

78
fun main() {
@@ -17,7 +18,7 @@ fun main() {
1718
}
1819

1920
fun htmlToCompose(html: String): String {
20-
val doc = Jsoup.parse(html);
21+
val doc = Jsoup.parse(html, Parser.xmlParser());
2122

2223
return doc.body().childNodes().joinToString(separator = "") {
2324
getMyNode(it).print()
Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
1-
H1 {
2-
Text("The input element")
3-
4-
}
5-
Form (action = "/action_page.php"){
6-
Label (forId = "fname"){
7-
Text("First name:")
8-
9-
}
10-
Input (attrs = {
11-
id("fname")
12-
name("fname")
13-
}, type = InputType.Text)
14-
Br {}
15-
Br {}
16-
Label (forId = "lname"){
17-
Text("Last name:")
18-
19-
}
20-
Input (attrs = {
21-
id("lname")
22-
name("lname")
23-
}, type = InputType.Text)
24-
Br {}
25-
Br {}
26-
Input (attrs = {
27-
attr("value","Submit")
28-
}, type = InputType.Submit)
29-
1+
Button (attrs = {
2+
name("button")
3+
attr("type","button")
4+
style {
5+
margin(16.px)
6+
padding(16.px)
7+
property("background-color","darkblue")
8+
property("color","aliceblue")
9+
borderRadius(4.px)
10+
fontSize(12.px)
3011
}
31-
P {
32-
Text("Click the \"Submit\" button and the form-data will be sent to a page on the server called \"action_page.php\".")
12+
attr("onClick","alert('Hello World!')")
13+
}){
14+
Text("Click Me!")
3315

3416
}
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
<!DOCTYPE html>
2-
<html>
3-
<body>
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Document</title>
5+
</head>
6+
<body>
47

5-
<h1>The input element</h1>
8+
<button name="button" type="button" style="margin: 16px; padding: 16px; background-color: darkblue; color: aliceblue;border-radius: 4px;font-size: 12px" onClick="alert('Hello World!')">Click Me!</button>
69

7-
<form action="/action_page.php">
8-
<label for="fname">First name:</label>
9-
<input type="text" id="fname" name="fname"><br><br>
10-
<label for="lname">Last name:</label>
11-
<input type="text" id="lname" name="lname"><br><br>
12-
<input type="submit" value="Submit">
13-
</form>
14-
15-
<p>Click the "Submit" button and the form-data will be sent to a page on the
16-
server called "action_page.php".</p>
17-
18-
</body>
19-
</html>
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)