diff --git a/snark-document-builder/src/main/kotlin/MdParser.kt b/snark-document-builder/src/main/kotlin/MdParser.kt index d502d41..0091cd5 100644 --- a/snark-document-builder/src/main/kotlin/MdParser.kt +++ b/snark-document-builder/src/main/kotlin/MdParser.kt @@ -7,12 +7,14 @@ import java.nio.file.Path private val MARKDOWN_PARSER = "snark-document-builder/src/main/nodejs/MarkdownParser.js" private val SNARK_PARSER = "snark-document-builder/src/main/python/SnarkParser.py" -public suspend fun parseMd(mdFile: ByteArray): MdAstRoot { - return jacksonObjectMapper() - .readValue(ProcessBuilder("node", MARKDOWN_PARSER, mdFile.toString()) +public suspend fun parseMd(mdFile: ByteArray, parserPath: String = MARKDOWN_PARSER): MdAstRoot { + val process = ProcessBuilder("node", parserPath, String(mdFile)) + val result = process .redirectOutput(ProcessBuilder.Redirect.PIPE) .redirectError(ProcessBuilder.Redirect.INHERIT) - .start().inputStream.bufferedReader().readText()) + .start().inputStream.bufferedReader().readText() + + return jacksonObjectMapper().readValue(result) } public suspend fun buildDependencyGraphNode(mdFile: ByteArray, path: Path): DependencyGraphNode {