diff --git a/compiler/src/knitr/__test__/knitr.test.ts b/compiler/src/knitr/__test__/knitr.test.ts index 396edb1f..157dae33 100644 --- a/compiler/src/knitr/__test__/knitr.test.ts +++ b/compiler/src/knitr/__test__/knitr.test.ts @@ -347,4 +347,20 @@ describe('knitr', () => { expect(ignoreWhitespace(html)).toBe(result); }, 120000); + + it('should remove python warnings from the top of knitr output', async () => { + const { md } = await testProcessor(` + WARNING - All triples will be processed in the same batch (batches_count=1). + When processing large graphs it is recommended to batch the input knowledge + graph instead. + + ## Introduction + + In the first two week of this course we have focused on the use of networks + to analyse social systems, using a mixture of global statistics, node + statistics, and ERGM modelling. + `); + + expect(md.trim().startsWith('WARNING')).toBe(false); + }); }); diff --git a/compiler/src/knitr/knitr.ts b/compiler/src/knitr/knitr.ts index 631a0c9e..90b329ba 100644 --- a/compiler/src/knitr/knitr.ts +++ b/compiler/src/knitr/knitr.ts @@ -153,6 +153,7 @@ function reportErrors(response: string, file: VFile) { async function formatResponse(response: string) { let md = response; md = removeCustomPythonBinNotice(md); + md = removePythonWarningMessage(md); md = addCodeBlockClasses(md); md = addErrorCodeBlock(md); md = removeHashSigns(md); @@ -165,6 +166,10 @@ function removeCustomPythonBinNotice(md: string) { return md.replace(/^\$python\s\[1\]\s"\S+"/, ''); } +function removePythonWarningMessage(md: string) { + return md.replace(/^WARNING - .+?[\r\n]+/m, ''); +} + function addCodeBlockClasses(md: string) { return md .split('\n')