From 6c8210bffadd252fc4448a914ac4e9592f0a4ff7 Mon Sep 17 00:00:00 2001 From: NikhilWanpal Date: Wed, 2 May 2018 01:27:20 +0530 Subject: [PATCH] Issue-27: BugFix: html entities breaking rendering in plantuml. BugFix: part of html was getting saved to file as uml, potential failure --- render-plantuml/render-plantuml.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/render-plantuml/render-plantuml.qml b/render-plantuml/render-plantuml.qml index 2a90675..a4eabaa 100644 --- a/render-plantuml/render-plantuml.qml +++ b/render-plantuml/render-plantuml.qml @@ -65,6 +65,8 @@ QtObject { while (match != null) { var matchedUml = match[1].replace(/\n/gi, "\\n"); var filePath = workDir + "/" + note.id + "_" + (++index); + + matchedUml = matchedUml.replace(/>/g, ">").replace(/</g, "<").replace(/"/g, "\\\"").replace(/"/g, "\\\"").replace(/&/g, "&"); var params = ["-e", "require('fs').writeFileSync('" + filePath + "', \"" + matchedUml + "\", 'utf8');"]; var result = script.startSynchronousProcess("node", params, html); @@ -108,7 +110,7 @@ QtObject { * @return {string} the modfied html or an empty string if nothing should be modified */ function noteToMarkdownHtmlHook(note, html) { - var plantumlSectionRegex = /
([\s\S]*?)<\/pre>/gmi;
+        var plantumlSectionRegex = /
([\s\S]*?)(<\/code>)?<\/pre>/gmi;
         
         var plantumlFiles = extractPlantUmlText(html, plantumlSectionRegex, note);