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(markdown): Always render noteblock titles on its own line #11548

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

Conversation

queengooborg
Copy link
Collaborator

Summary

This PR updates the GFM noteblock rendering to always put the title ("Note:", "Warning:", etc.) on its own line, regardless of how the Markdown is formatted.

Important

GitHub has named noteblocks as "Alerts".

Problem

One issue that is currently preventing us from performing mass GFM noteblock conversion is a Prettier bug, which causes lines starting with special characters (like [ or `) to get wrapped to the same line as the noteblock declaration (like > [!NOTE] > `code` cannot be used).

Solution

The simplest solution I could think of was to update the rendering to be more similar to how GitHub renders its noteblocks.

Note

This is how GitHub's noteblocks look.


Screenshots

Test Markdown

> [!NOTE]
> This is a note.

> [!WARNING]
> This is a warning.

> [!CALLOUT]
> This is a callout.

> [!NOTE]
>
> This is a multi-line note.

> [!WARNING]
>
> This is a multi-line warning.

> [!CALLOUT]
>
> This is a multi-line callout.

Before

before

After

after

@queengooborg queengooborg requested a review from a team as a code owner July 26, 2024 16:46
@github-actions github-actions bot added the markdown markdown related issues and pull requests label Jul 26, 2024
@fiji-flo
Copy link
Contributor

I see that this is blocking moving to the new syntax. I feel very strongly about letting a tool like prettier decide how MDN looks like. I looked at prettier and opened a PR to fix this almost 4 year old issue. I actually affects our note cards and code blocks as a whole.

@fiji-flo
Copy link
Contributor

As for now we could also just use:

> [!NOTE] something

for the same line note cards. GitHub does not support this but yari/rari does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
markdown markdown related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants