fix(plugin-md-power): fix potential null pointer exceptions when parsing collapse containers (#866)

This commit is contained in:
pengzhanbo 2026-03-05 14:41:47 +08:00 committed by GitHub
parent ca51a345fb
commit 916e9141d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,10 +109,10 @@ function parseCollapse(tokens: Token[], index: number, attrs: CollapseMeta): num
idx++ idx++
const inlineToken = tokens[i + 2] const inlineToken = tokens[i + 2]
const firstToken = inlineToken.children![0] const firstToken = inlineToken.children?.[0]
let flag: string = '' let flag: string = ''
let expand: boolean | undefined let expand: boolean | undefined
if (firstToken.type === 'text') { if (firstToken?.type === 'text') {
firstToken.content = firstToken.content.trim().replace(/^:[+\-]\s*/, (match) => { firstToken.content = firstToken.content.trim().replace(/^:[+\-]\s*/, (match) => {
flag = match.trim() flag = match.trim()
return '' return ''