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 { HeadingLevel, ImageRun, Paragraph, TextRun } from 'docx'
|
||||||
import type Token from 'markdown-it/lib/token'
|
import type Token from 'markdown-it/lib/token'
|
||||||
import { StyleId } from '@md-report/types'
|
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 {
|
export function parseInline(props: { tokens: Token[]; style?: StyleId; headingLevel?: number; isUL?: boolean; isOL?: boolean }): Paragraph {
|
||||||
// Props.
|
// Props.
|
||||||
|
@ -95,7 +95,9 @@ export function parseText(tokens: Token[]): TextRun {
|
||||||
break
|
break
|
||||||
// Normal text.
|
// Normal text.
|
||||||
default:
|
default:
|
||||||
options = { ...options, text: token.content }
|
// 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 MathBlockRegExp = /^\$\$\n([^]*)\n\$\$$/
|
||||||
|
|
||||||
|
export const CommentRegExp = /^\<\!\-[^]*\-\>$/
|
||||||
|
|
Loading…
Reference in New Issue