fix: 修复钉钉Markdown消息内不支持html代码显示的bug,对html标签进行转义 #213
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在提出此拉取请求时,我确认了以下几点(请复选框):
钉钉官方Markdown消息是不支持代码块语法的,官方文档如下:
https://open.dingtalk.com/document/orgapp/message-types-and-data-format#title-afc-2nh-5kk
此问题的根本原因是钉钉pc端在Markdown消息内会将html代码进行渲染(哪怕html代码是在代码块内也会进行渲染,从而导致无法正常显示相关代码),而手机端无法显示(显示空白)含有html代码的Markdown消息,本质上是钉钉的bug。
代码块缩进问题暂无法解决,因不管是四个空格,还是Tab,在钉钉上均会顶格显示,建议复制代码后用IDE进行代码格式化,针对缩进严格的语言,例如Python,不确定的建议手机端查看下代码块的缩进。
经验证,经过转义后,html代码显示问题已修复(无论是代码块内,还是代码块外均无显示问题),如下图所示: