Skip to content
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

Conversation

aringenbach
Copy link
Contributor

Fixes #5355

This is partly adapted from similar issue in element-web (details available on linked issue description).

@github-actions
Copy link

github-actions bot commented Feb 15, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/4DkfdJ

Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

/// 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() {
Copy link
Member

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 😅

Copy link
Contributor Author

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)
Copy link
Contributor Author

@aringenbach aringenbach Feb 16, 2022

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)

Copy link
Member

@stefanceriu stefanceriu left a 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 👍

@aringenbach aringenbach merged commit 057cb9e into develop Feb 18, 2022
@aringenbach aringenbach deleted the aringenbach/5355_fix_links_with_markdown_formatting_symbols branch February 18, 2022 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Links containing markdown formatting (eg underscores) are interpreted as markdown
2 participants