-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix HTML render for links containing Markdown formatting #5587
Fix HTML render for links containing Markdown formatting #5587
Conversation
📱 Scan the QR code below to install the build for this PR. If you can't scan the QR code you can install the build via this link: https://i.diawi.com/4DkfdJ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
Riot/Modules/MatrixKit/Utils/EventFormatter/MarkdownToHTMLRenderer.swift
Outdated
Show resolved
Hide resolved
/// Repairs links that were broken down by markdown formatting. | ||
/// Should be used on the first node of libcmark's AST | ||
/// (e.g. the object returned by DownASTRenderer.stringToAST). | ||
func repairLinks() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not going to pretend I understand everything this does but I trust that we'll find out pretty fast if it breaks anything 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I already added a nice coverage with unit tests. But if someone ever finds a string that manages to break it, I suppose we will just have to fix it and extend our unit tests with it :)
If you have suggestions of weird strings that I could add to unit tests, feel free
cmark_node_set_literal(node.pointee.first_child, "") | ||
let newIterator = cmark_iter_new(node) | ||
_ = cmark_iter_next(newIterator) | ||
cmark_node_unlink(node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these unlink actually don't free mem (at least not immediately), I will update for that,
I'll take a look if I can as well make sure that created node that I link manually to the AST are properly freed (hopefully they are, cause freeing manually afterwards would look terrible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
Fixes #5355
This is partly adapted from similar issue in element-web (details available on linked issue description).