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: Allow table rendering in markdown preview tool #4858

Merged

Conversation

MaoShizhong
Copy link
Contributor

@MaoShizhong MaoShizhong commented Nov 27, 2024

Because

Some of our lessons have markdown tables but the necessary table tags (table/thead/tbody/tr/th/td) are not included in rails-html-sanitizer's default allowed tags, meaning our markdown preview tool won't render tables.

This PR

  • Adds table/thead/tboyd/tr/th/td tags to Markdown::PreviewComponent#allowed_tags.

Issue

N/A

Additional Information

For QA

Go to the markdown preview tool and enter

| Verb   | Action | Example                                       |
| ------ | ------ | --------------------------------------------- |
| POST   | Create | `POST /posts` Creates a new blog post         |
| GET    | Read   | `GET /posts/:postid` Fetches a single post    |
| PUT    | Update | `PUT /posts/:postid` Updates a single post    |
| DELETE | Delete | `DELETE /posts/:postid` Deletes a single post |

Which will fail to render the table (which renders properly in the actual lessons):

current broken markdown preview tool

Compare that to when the 6 relevant tags are whitelisted in #allowed_tags, which allows rendering of markdown tables as expected as below:

fixed markdown preview tool

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the keyword: brief description of change format, using one of the following keywords:
    • Feature - adds new or amends existing user-facing behavior
    • Chore - changes that have no user-facing value, refactors, dependency bumps, etc
    • Fix - bug fixes
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • I have verified all tests and linters pass after making these changes.
  • If this PR addresses an open issue, it is linked in the Issue section
  • If applicable, this PR includes new or updated automated tests

Copy link
Member

@KevinMulhern KevinMulhern left a comment

Choose a reason for hiding this comment

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

Nice! 🤌

Thanks @MaoShizhong

@MaoShizhong
Copy link
Contributor Author

Can't merge this myself anymore :P

@KevinMulhern
Copy link
Member

Sorry, forgot myself 😢

@KevinMulhern KevinMulhern merged commit b4009fe into TheOdinProject:main Nov 28, 2024
5 checks passed
@MaoShizhong MaoShizhong deleted the fix/markdown-preview-tables branch November 28, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants