Skip to content

Fix: Preserve HTML in runkit source code blocks #22099

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nee-k
Copy link

@nee-k nee-k commented Jul 9, 2025

This change modifies the RunkitTag class to use inner_html instead of text when parsing the content, which preserves HTML tags in the runkit source.

Fixes #1228

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Related Tickets & Documents

  • Related Issue #
  • Closes #

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.

UI accessibility checklist

If your PR includes UI changes, please utilize this checklist:

  • Semantic HTML implemented?
  • Keyboard operability supported?
  • Checked with axe DevTools and addressed Critical and Serious issues?
  • Color contrast tested?

For more info, check out the
Forem Accessibility Docs.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

I have read the CLA Document and I hereby sign the CLA

This change modifies the RunkitTag class to use inner_html instead of text
when parsing the content, which preserves HTML tags in the runkit source.

Fixes forem#1228
@nee-k nee-k requested a review from a team as a code owner July 9, 2025 09:14
Copy link
Contributor

github-actions bot commented Jul 9, 2025

Thank you for opening this PR! We appreciate you!

For all pull requests coming from third-party forks we will need to
review the PR before we can process it through our CI pipelines.

A Forem Team member will review this contribution and get back to
you as soon as possible!

Copy link
Contributor

github-actions bot commented Jul 9, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@nee-k
Copy link
Author

nee-k commented Jul 9, 2025

I have read the CLA Document and I hereby sign the CLA

Copy link
Contributor

@benhalpern benhalpern left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

Copy link
Contributor

@benhalpern benhalpern left a comment

Choose a reason for hiding this comment

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

Hmmm actually looks like this failing test needs to be looked into:

  1) RunkitTag#render preserves HTML tags in content
     Failure/Error: expect(rendered).not_to include('🍔Hello, World!🍔') # This would indicate HTML was stripped
       expected "<div class=\"runkit-element\">\n  <code style=\"display: none\">\n    const myVar = 9001\n\n  </code...ot;&lt;marquee&gt;🍔Hello, World!🍔&lt;/marquee&gt;&quot;\n    }\n};\n&lt;/p&gt;\n  </code>\n</div>\n" not to include "🍔Hello, World!🍔"

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.

HTML is stripped from runkit source
2 participants