diff --git a/packages/parser/src/inline.ts b/packages/parser/src/inline.ts index 74bb58a..cb9b891 100644 --- a/packages/parser/src/inline.ts +++ b/packages/parser/src/inline.ts @@ -5,7 +5,7 @@ import type { IImageOptions, IRunOptions, ParagraphChild } from 'docx' import { HeadingLevel, ImageRun, Paragraph, TextRun } from 'docx' import type Token from 'markdown-it/lib/token' import { StyleId } from '@md-report/types' -import { sliceInlineText } from './utils' +import { CommentRegExp, sliceInlineText } from './utils' export function parseInline(props: { tokens: Token[]; style?: StyleId; headingLevel?: number; isUL?: boolean; isOL?: boolean }): Paragraph { // Props. @@ -95,7 +95,9 @@ export function parseText(tokens: Token[]): TextRun { break // Normal text. default: - options = { ...options, text: token.content } + // No output for comments. + if (!token.content.match(CommentRegExp)) + options = { ...options, text: token.content } } } }) diff --git a/packages/parser/src/utils.ts b/packages/parser/src/utils.ts index c15365a..a2efad4 100644 --- a/packages/parser/src/utils.ts +++ b/packages/parser/src/utils.ts @@ -59,3 +59,5 @@ export function sliceInlineText(tokens: Token[]): SliceResult { } export const MathBlockRegExp = /^\$\$\n([^]*)\n\$\$$/ + +export const CommentRegExp = /^\<\!\-[^]*\-\>$/