Skip to content

Conversation

@gadenbuie
Copy link
Collaborator

@gadenbuie gadenbuie commented Sep 5, 2025

Fixes #11

pkgload::load_all("pkg-r")

output_markdown_stream(
  "foo",
  content = "Here's a link to [wikipedia](https://wikipedia.org)."
)

output_markdown_stream(
  "foo",
  content = "Here's a link to [wikipedia](https://wikipedia.org).",
  content_type = "semi-markdown"
)

@gadenbuie gadenbuie force-pushed the fix/11-links-in-chat branch from cca8f4a to a227602 Compare September 5, 2025 13:24
@gadenbuie gadenbuie force-pushed the fix/11-links-in-chat branch from a227602 to 0b3e7b0 Compare September 5, 2025 13:28
@gadenbuie gadenbuie requested a review from cpsievert September 5, 2025 13:28
@cpsievert
Copy link
Collaborator

Have you tested that this works? I can confirm the rel="noopener noreferrer" is getting added, but it appears the target="_blank" gets stripped out, probably by DOMpurify cure53/DOMPurify#317

@gadenbuie
Copy link
Collaborator Author

Have you tested that this works? I can confirm the rel="noopener noreferrer" is getting added, but it appears the target="_blank" gets stripped out, probably by DOMpurify cure53/DOMPurify#317

Oh shoot, yeah I saw the rel attribute was added and thought it was both. I'll fix the sanitization too

Now a two step process:
* Markdown renderer adds `data-external-link` to external links
* DOMPurify adds `target="_blank" rel="noopener noreferrer"` to links with that attribute

Otherwise sanitization strips out the target attribute.
@gadenbuie
Copy link
Collaborator Author

@cpsievert okay, now it works! 😃

@gadenbuie gadenbuie merged commit e04f8bc into main Sep 6, 2025
16 checks passed
@gadenbuie gadenbuie deleted the fix/11-links-in-chat branch September 6, 2025 12:20
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.

Small suggestion - render links so that they open in a new tab

3 participants