diff --git a/src/magick.ts b/src/magick.ts index adc9b11..8b6cd65 100644 --- a/src/magick.ts +++ b/src/magick.ts @@ -15,7 +15,6 @@ export async function svgElementToPNGFile(svgElement:string, pngFilePath:string) try { await utility.execFile('magick', [info.path, pngFilePath]) } catch(error) { - console.log(error) throw "ImageMagick is required to be installed to convert svg to png.\n" + error.toString() } return pngFilePath diff --git a/src/markdown-engine.ts b/src/markdown-engine.ts index 1dae351..86d32b6 100644 --- a/src/markdown-engine.ts +++ b/src/markdown-engine.ts @@ -1027,6 +1027,7 @@ export class MarkdownEngine { } else { result = await CodeChunkAPI.run(code, this.fileDirectoryPath, codeChunkData.options) } + codeChunkData.plainResult = result if (codeChunkData.options['modify_source'] && ('code_chunk_offset' in codeChunkData.options)) { codeChunkData.result = '' @@ -1189,6 +1190,7 @@ export class MarkdownEngine { code, options: options, result: '', + plainResult: '', running: false, prev: previousCodeChunkDataId, next: null diff --git a/src/process-graphs.ts b/src/process-graphs.ts index 1ca9259..150cc3a 100644 --- a/src/process-graphs.ts +++ b/src/process-graphs.ts @@ -185,6 +185,8 @@ export async function processGraphs(text:string, const pngFilePath = await convertSVGToPNGFile($.html('svg'), lines, start, end, false) result = `![](${pngFilePath}) \n` } + } else if (currentCodeChunk.options['output'] === 'markdown') { + result = currentCodeChunk.plainResult } lines[end] += ('\n' + result) diff --git a/src/typings/mpe.d.ts b/src/typings/mpe.d.ts index f34ac69..7d4d340 100644 --- a/src/typings/mpe.d.ts +++ b/src/typings/mpe.d.ts @@ -54,6 +54,11 @@ interface CodeChunkData { /** * result after running code chunk */ + plainResult: string, + + /** + * result after formatting according to options['output'] format + */ result: string, /** * whether is running the code chunk or not