File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
main/kotlin/de/jensklingenberg/htmltocfw/converter Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package de.jensklingenberg.htmltocfw.converter
2
2
3
3
import de.jensklingenberg.htmltocfw.converter.node.getMyNode
4
4
import org.jsoup.Jsoup
5
+ import org.jsoup.parser.ParseSettings
5
6
import org.jsoup.parser.Parser
6
7
import java.io.File
7
8
@@ -18,7 +19,9 @@ fun main() {
18
19
}
19
20
20
21
fun htmlToCompose (html : String ): String {
21
- val doc = Jsoup .parse(html, Parser .xmlParser());
22
+ val parser = Parser .htmlParser();
23
+ parser.settings(ParseSettings (true , true ))
24
+ val doc = parser.parseInput(html," " )
22
25
23
26
return doc.body().childNodes().joinToString(separator = " " ) {
24
27
getMyNode(it).print ()
Original file line number Diff line number Diff line change 1
- import de.jensklingenberg.htmltocfw.converter.getMyNode
2
1
import de.jensklingenberg.htmltocfw.converter.htmlToCompose
2
+ import de.jensklingenberg.htmltocfw.converter.node.getMyNode
3
3
import org.jsoup.Jsoup
4
4
import org.junit.jupiter.api.Test
5
5
import kotlin.test.assertEquals
6
6
7
- class myTest {
7
+ class MyTest {
8
8
9
9
@Test
10
10
fun ButtonTest (){
@@ -15,6 +15,7 @@ class myTest {
15
15
attr("onclick","alert('Hello world!')")
16
16
}){
17
17
Text("Click Me!")
18
+
18
19
}
19
20
20
21
""" .trimIndent()
@@ -34,6 +35,7 @@ class myTest {
34
35
attr("width","500")
35
36
attr("height","600")
36
37
}, src = "img_girl.jpg", alt = "Girl in a jacket")
38
+
37
39
""" .trimIndent()
38
40
39
41
val text = doc.body().childNodes().joinToString(separator = " " ) {
@@ -45,10 +47,11 @@ class myTest {
45
47
46
48
@Test
47
49
fun nodeATest (){
48
- val html = """ <a href="https://www.w3schools.com">Visit W3Schools.com!</a> """
50
+ val html = """ <a href="https://www.w3schools.com">Visit W3Schools.com!</a> """
49
51
val exp = """
50
52
A (href = "https://www.w3schools.com"){
51
53
Text("Visit W3Schools.com!")
54
+
52
55
}
53
56
54
57
""" .trimIndent()
@@ -60,10 +63,11 @@ class myTest {
60
63
61
64
@Test
62
65
fun failedTest (){
63
- val html = """ a href="https://www.w3schools.com<< ">Visit W3Schools.com!</a> """
66
+ val html = """ < a href="https://www.w3schools.com">Visit W3Schools.com!</a> """
64
67
val exp = """
65
68
A (href = "https://www.w3schools.com"){
66
69
Text("Visit W3Schools.com!")
70
+
67
71
}
68
72
69
73
""" .trimIndent()
You can’t perform that action at this time.
0 commit comments