diff --git a/snark-document-builder/src/main/kotlin/MdParser.kt b/snark-document-builder/src/main/kotlin/MdParser.kt index 0f6d90b..8186b23 100644 --- a/snark-document-builder/src/main/kotlin/MdParser.kt +++ b/snark-document-builder/src/main/kotlin/MdParser.kt @@ -1,7 +1,16 @@ package documentBuilder +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue + +private val MARKDOWN_PARSER = "../nodejs/MarkdownParser.js" + public suspend fun parseMd(mdFile: ByteArray): MdAstRoot { - TODO() + return jacksonObjectMapper() + .readValue(ProcessBuilder("node", MARKDOWN_PARSER, mdFile.toString()) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .redirectError(ProcessBuilder.Redirect.INHERIT) + .start().inputStream.bufferedReader().readText()) } public suspend fun buildDependencyGraphNode(mdFile: ByteArray): DependencyGraphNode {