2024-09-28 11:48:25 +03:00
|
|
|
package center.sciprog.snark.documents
|
|
|
|
|
2024-04-16 17:46:00 +03:00
|
|
|
import io.ktor.server.application.Application
|
|
|
|
import io.ktor.server.cio.CIO
|
|
|
|
import io.ktor.server.engine.embeddedServer
|
2024-04-30 19:00:37 +03:00
|
|
|
import kotlinx.html.ScriptCrossorigin
|
|
|
|
import kotlinx.html.link
|
|
|
|
import kotlinx.html.script
|
|
|
|
import space.kscience.snark.html.document.allDocuments
|
2024-09-28 11:48:25 +03:00
|
|
|
import space.kscience.snark.ktor.snarkApplication
|
2024-04-16 17:46:00 +03:00
|
|
|
|
|
|
|
@Suppress("unused")
|
2024-04-30 19:00:37 +03:00
|
|
|
fun Application.renderAllDocuments() = snarkApplication {
|
|
|
|
allDocuments(
|
|
|
|
headers = {
|
|
|
|
link {
|
|
|
|
rel = "stylesheet"
|
|
|
|
href = "https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.css"
|
|
|
|
attributes["integrity"] = "sha384-wcIxkf4k558AjM3Yz3BBFQUbk/zgIYC2R0QpeeYb+TwlBVMrlgLqwRjRtGZiK7ww"
|
|
|
|
attributes["crossorigin"] = "anonymous"
|
|
|
|
}
|
|
|
|
script {
|
|
|
|
defer = true
|
|
|
|
src = "https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.js"
|
|
|
|
integrity = "sha384-hIoBPJpTUs74ddyc4bFZSM1TVlQDA60VBbJS0oA934VSz82sBx1X7kSx2ATBDIyd"
|
|
|
|
crossorigin = ScriptCrossorigin.anonymous
|
|
|
|
}
|
|
|
|
script {
|
|
|
|
defer = true
|
|
|
|
src = "https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/contrib/auto-render.min.js"
|
|
|
|
integrity = "sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk"
|
|
|
|
crossorigin = ScriptCrossorigin.anonymous
|
|
|
|
attributes["onload"] = "renderMathInElement(document.body);"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2024-04-16 17:46:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun main() {
|
2024-09-28 11:48:25 +03:00
|
|
|
embeddedServer(CIO, module = Application::renderAllDocuments).start(true)
|
2024-04-16 17:46:00 +03:00
|
|
|
}
|