feat(parser): skip comment
This commit is contained in:
parent
cffd65ec2d
commit
cd5ac19179
|
@ -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,6 +95,8 @@ export function parseText(tokens: Token[]): TextRun {
|
|||
break
|
||||
// Normal text.
|
||||
default:
|
||||
// No output for comments.
|
||||
if (!token.content.match(CommentRegExp))
|
||||
options = { ...options, text: token.content }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,3 +59,5 @@ export function sliceInlineText(tokens: Token[]): SliceResult {
|
|||
}
|
||||
|
||||
export const MathBlockRegExp = /^\$\$\n([^]*)\n\$\$$/
|
||||
|
||||
export const CommentRegExp = /^\<\!\-[^]*\-\>$/
|
||||
|
|
Loading…
Reference in New Issue