From e0ef373c485570fea1195f24f96cbc18f1644866 Mon Sep 17 00:00:00 2001 From: "liubar.pa" Date: Fri, 5 May 2023 00:07:59 +0300 Subject: [PATCH] SNRK-71: parseMd is implemented --- snark-document-builder/src/main/kotlin/MdParser.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 {