Ikaleio / LiteLoaderQQNT-Markdown

为QQ添加Markdown渲染支持
Do What The F*ck You Want To Public License
123 stars 12 forks source link

引用(quote)未正常運作 #38

Closed EvanHsieh0415 closed 4 months ago

EvanHsieh0415 commented 6 months ago

輸入時:圖片

發送後:圖片

理想效果:

123 456

nfnfgo commented 4 months ago

After some preliminary checks it seems that this issue arises from unparsed HTML entities.

Specifically, the character '>' is converted to '\>' in HTML, which causes the markdown parser to fail to recognize blockquote formatting.

One quick fix is to detect and replace all occurrences of > into > in the retrieved innerHTML:

// renderer.js line37
return {
  mark: Array.from(msgPiece.getElementsByTagName("span"))
      .map((e) => e.innerHTML)
      .reduce((acc, x) => acc + x.replaceAll('>', '>'), ""), // Here add .replaceAll('>', '>')
  replace: null
}

There might be a more elegant solution, but this should work for now.

Example

## Quote Test

> Here is a blockquote.
>
> Multi-line is available.

## Nested Quote Test

> Outer
>
> Some content.
>> Inner
>> Inner content.

Output Screenshot:

image

Ikaleio commented 4 months ago

请更新到 2.0.0 版本