From f4598ba2201ff9bdfe98f69d37e27d28f3ec84bc Mon Sep 17 00:00:00 2001 From: Jerome Lelong Date: Wed, 15 Jul 2020 09:55:48 +0200 Subject: [PATCH] Update comments --- src/utils/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 6042f9398..98a02bab3 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -34,14 +34,16 @@ export function stripComments(text: string, commentSign: string): string { * Remove comments and verbatim content * * @param text A multiline string to be stripped + * @return the input text with comments and verbatim content removed. + * Note the number lines of the output matches the input */ export function stripCommentsAndVerbatim(text: string): string { - let content = text.replace(/([^\\]|^)%.*$/gm, '$1') // Strip comments + let content = text.replace(/([^\\]|^)%.*$/gm, '$1') content = content.replace(/\\verb\*?([^a-zA-Z0-9]).*\1/, '') const verbatimPattern = '\\\\begin{verbatim}.*\\\\end{verbatim}' const reg = RegExp(verbatimPattern, 'gms') content = content.replace(reg, (match, ..._args) => { - const len = match.split('\n').length + const len = Math.max(match.split('\n').length, 1) return '\n'.repeat(len - 1) }) return content