用 DSL 語法撰寫投影片
用 Kotlin 定義的語法
在特定領域做特定的事情
dslSlide {
content {
h2 { +"什麼是 DSL" }
b { +"領域特定語言" }
p { +"用 Kotlin 定義的語法" }
p { +"在特定領域做特定的事情" }
}
}
fun main() {
for (i in (0..5)) {
println("Hello World $i")
}
}
dslSlide {
val src = "kslides-examples/src/main/kotlin/content/HelloWorldK.kt"
val url = githubRawUrl("kslides", "kslides", src)
content {
h2 { +"包含程式碼區塊的 dslSlide" }
// Display lines 3-7 of the url content and highlight lines 1 and 5, 2 and 4, and finally 3
codeSnippet {
language = "kotlin"
highlightPattern = "[1,5|2,4|3]"
+include(url, "[3-7]")
}
}
}
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
{
"id":"444",
"language":"C",
"author":"Dennis Ritchie"
},
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
"books":[
{
"id":"444",
"language":"C",
"author":"Dennis Ritchie"
},
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
]
{
"books":[
{
"id":"444",
"language":"C",
"author":"Dennis Ritchie"
},
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
]
}
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
{
"id":"444",
"language":"C",
"author":"Dennis Ritchie"
},
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
"books":[
{
"id":"444",
"language":"C",
"author":"Dennis Ritchie"
},
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
]
{
"books":[
{
"id":"444",
"language":"C",
"author":"Dennis Ritchie"
},
{
"id":"555",
"language":"C++",
"author":"Bjarne Stroustrup"
}
]
}