Skip to content

Commit

Permalink
added plainResult for code chunk data interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
shd101wyy committed Jun 20, 2017
1 parent e1d8417 commit 2f6f70d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/magick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/markdown-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -1189,6 +1190,7 @@ export class MarkdownEngine {
code,
options: options,
result: '',
plainResult: '',
running: false,
prev: previousCodeChunkDataId,
next: null
Expand Down
2 changes: 2 additions & 0 deletions src/process-graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/typings/mpe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2f6f70d

Please sign in to comment.