Compare commits
No commits in common. "e2ef4b1c5b0bc2735ea6ee9dfbebeafaf96bea28" and "81f999761812286fb020a9f93995900c9d6604a8" have entirely different histories.
e2ef4b1c5b
...
81f9997618
@ -1,23 +1,25 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("space.kscience.gradle.mpp")
|
id("space.kscience.gradle.mpp")
|
||||||
alias(spclibs.plugins.ktor)
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val snarkVersion: String by extra
|
||||||
|
val ktorVersion = space.kscience.gradle.KScienceVersions.ktorVersion
|
||||||
|
|
||||||
kscience {
|
kscience {
|
||||||
jvm{
|
jvm{
|
||||||
withJava()
|
withJava()
|
||||||
}
|
}
|
||||||
useContextReceivers()
|
useContextReceivers()
|
||||||
useKtor()
|
|
||||||
|
|
||||||
jvmMain {
|
jvmMain {
|
||||||
implementation(projects.snarkKtor)
|
implementation(projects.snarkKtor)
|
||||||
implementation("io.ktor:ktor-server-cio")
|
implementation("io.ktor:ktor-server-cio:$ktorVersion")
|
||||||
implementation(spclibs.logback.classic)
|
implementation(spclibs.logback.classic)
|
||||||
}
|
}
|
||||||
|
|
||||||
jvmTest{
|
jvmTest{
|
||||||
implementation("io.ktor:ktor-server-tests")
|
implementation("io.ktor:ktor-server-tests:$ktorVersion")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClass.set("center.sciprog.snark.documents.MainKt")
|
mainClass.set("center.sciprog.snark.documents.Mainkt")
|
||||||
|
|
||||||
val isDevelopment: Boolean = project.ext.has("development")
|
val isDevelopment: Boolean = project.ext.has("development")
|
||||||
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment", "-Xmx200M")
|
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment", "-Xmx200M")
|
||||||
|
@ -14,7 +14,9 @@ Curabitur hendrerit hendrerit rutrum. Nullam elementum libero a nisi viverra ali
|
|||||||
|
|
||||||
Paragraph
|
Paragraph
|
||||||
|
|
||||||
$ \int_a^b {f(x)} = const $
|
$$
|
||||||
|
\int_a^b {f(x)} = const
|
||||||
|
$$
|
||||||
|
|
||||||
### Section ${section(2)}
|
### Section ${section(2)}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import io.ktor.server.engine.embeddedServer
|
|||||||
import kotlinx.html.ScriptCrossorigin
|
import kotlinx.html.ScriptCrossorigin
|
||||||
import kotlinx.html.link
|
import kotlinx.html.link
|
||||||
import kotlinx.html.script
|
import kotlinx.html.script
|
||||||
import kotlinx.html.unsafe
|
|
||||||
import space.kscience.snark.html.document.allDocuments
|
import space.kscience.snark.html.document.allDocuments
|
||||||
import space.kscience.snark.ktor.snarkApplication
|
import space.kscience.snark.ktor.snarkApplication
|
||||||
|
|
||||||
@ -33,22 +32,6 @@ fun Application.renderAllDocuments() = snarkApplication {
|
|||||||
crossorigin = ScriptCrossorigin.anonymous
|
crossorigin = ScriptCrossorigin.anonymous
|
||||||
attributes["onload"] = "renderMathInElement(document.body);"
|
attributes["onload"] = "renderMathInElement(document.body);"
|
||||||
}
|
}
|
||||||
script {
|
|
||||||
unsafe {
|
|
||||||
+"""
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
renderMathInElement(document.body, {
|
|
||||||
delimiters: [
|
|
||||||
{left: '$$', right: '$$', display: true},
|
|
||||||
{left: '$', right: '$', display: false},
|
|
||||||
],
|
|
||||||
throwOnError : false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
""".trimIndent()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package space.kscience.snark.html
|
package space.kscience.snark.html
|
||||||
|
|
||||||
import kotlinx.css.html
|
|
||||||
import kotlinx.html.HTML
|
import kotlinx.html.HTML
|
||||||
import kotlinx.html.dom.append
|
import kotlinx.html.stream.createHTML
|
||||||
import kotlinx.html.dom.document
|
import kotlinx.html.visitTagAndFinalize
|
||||||
import kotlinx.html.dom.serialize
|
|
||||||
import kotlinx.html.html
|
|
||||||
import space.kscience.dataforge.data.DataSink
|
import space.kscience.dataforge.data.DataSink
|
||||||
import space.kscience.dataforge.data.DataTree
|
import space.kscience.dataforge.data.DataTree
|
||||||
import space.kscience.dataforge.data.wrap
|
import space.kscience.dataforge.data.wrap
|
||||||
@ -18,22 +15,20 @@ public fun interface HtmlPage {
|
|||||||
public fun renderPage()
|
public fun renderPage()
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
|
|
||||||
public fun createHtmlString(
|
public fun createHtmlString(
|
||||||
pageContext: PageContext,
|
pageContext: PageContext,
|
||||||
dataSet: DataTree<*>?,
|
dataSet: DataTree<*>?,
|
||||||
page: HtmlPage,
|
page: HtmlPage,
|
||||||
): String = document {
|
): String = createHTML().run {
|
||||||
append.html {
|
HTML(kotlinx.html.emptyMap, this, null).visitTagAndFinalize(this) {
|
||||||
with(PageContextWithData(pageContext, dataSet ?: DataTree.EMPTY)) {
|
with(PageContextWithData(pageContext, dataSet ?: DataTree.EMPTY)) {
|
||||||
with(page) {
|
with(page) {
|
||||||
renderPage()
|
renderPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.serialize(true)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,9 +9,11 @@ import org.intellij.markdown.ast.findChildOfType
|
|||||||
import org.intellij.markdown.ast.getTextInNode
|
import org.intellij.markdown.ast.getTextInNode
|
||||||
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
|
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
|
||||||
import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
|
import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
|
||||||
|
import org.intellij.markdown.flavours.space.SFMFlavourDescriptor
|
||||||
import org.intellij.markdown.html.*
|
import org.intellij.markdown.html.*
|
||||||
import org.intellij.markdown.parser.LinkMap
|
import org.intellij.markdown.parser.LinkMap
|
||||||
import org.intellij.markdown.parser.MarkdownParser
|
import org.intellij.markdown.parser.MarkdownParser
|
||||||
|
import space.kscience.snark.SnarkReader
|
||||||
|
|
||||||
private class SnarkInlineLinkGeneratingProvider(
|
private class SnarkInlineLinkGeneratingProvider(
|
||||||
baseURI: URI?,
|
baseURI: URI?,
|
||||||
|
Loading…
Reference in New Issue
Block a user