Enable rich-text messages in matrix channel#1370
Conversation
yinwm
left a comment
There was a problem hiding this comment.
Review Summary
This PR adds rich-text message support for the Matrix channel by converting Markdown to HTML format. The implementation is clean and well-structured.
✅ What's Good
-
Clean code reuse: The
messageContent()method is properly shared betweenSend()andEditMessage(), eliminating code duplication. -
Correct Matrix spec compliance: The implementation correctly keeps the original Markdown in
Bodyas fallback while providing HTML inFormattedBody:mc := &event.MessageEventContent{MsgType: event.MsgText, Body: text} // fallback mc.FormattedBody = markdownToHTML(text) // rich text
-
Sensible defaults: Richtext is enabled by default (when
MessageFormatis empty or "richtext"), with explicit "plain" option for users who prefer raw Markdown. -
Good test coverage: Both
TestMarkdownToHTMLandTestMessageContentcover the key scenarios including richtext, plain, and default configurations. -
Documentation: README is updated with clear explanation of the new
message_formatoption.
🔒 Security
The gomarkdown/markdown library doesn't parse raw HTML by default, and Matrix clients are responsible for HTML sanitization per the spec. The generated tags (<strong>, <em>, <code>, <pre>, <a>, headers, lists, etc.) are all within Matrix's allowed HTML subset.
LGTM! 🚀
|
thanks for the pr |
* Enable rich-text messages in matrix channel * Fix lint
* Enable rich-text messages in matrix channel * Fix lint
* Enable rich-text messages in matrix channel * Fix lint
* Enable rich-text messages in matrix channel * Fix lint
📝 Description
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Details
☑️ Checklist