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

Add support for Alerts #67

Closed
4 tasks done
tukusejssirs opened this issue Jun 29, 2024 · 10 comments
Closed
4 tasks done

Add support for Alerts #67

tukusejssirs opened this issue Jun 29, 2024 · 10 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@tukusejssirs
Copy link

tukusejssirs commented Jun 29, 2024

Initial checklist

Problem

The Alerts feature is not properly parsed ATM.

The issue is that > [!NOTE] is converted to > \[!NOTE] ([ is escaped) which is an invalid Alert syntax.

Here are all possible alert types currently supported by GFM:

> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better or more easily.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.

Solution

> [!NOTE] (and other alert types) should be left intact.

Alternatives

Of course, can remove the backslashes using String(file).replace(/^> \\\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\][ \t]*$/gm, '> [!$1]'), however, I think remark-gfm should support this out of box. 😉

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jun 29, 2024
@remcohaszing
Copy link
Member

GitHub looks at the textual meaning of the blockquote content. It works fine with escaped [ characters.


> \[!NOTE]
> Useful information that users should know, even when skimming content.

yields:

Note

Useful information that users should know, even when skimming content.


> [!NOTE]
> Useful information that users should know, even when skimming content.

[!note]: https://example.com

yields:

!NOTE
Useful information that users should know, even when skimming content.

@tukusejssirs
Copy link
Author

tukusejssirs commented Jun 29, 2024

Thanks for taking the time to reply to my issue! 🙏

Update: It actually does work using the backslash, although it seems to me like it is not the format they recommend to be used.

@wooorm
Copy link
Member

wooorm commented Jun 30, 2024

> [!NOTE]
Some note

[!note]: https://example.com

Yields:

!NOTE
Some note

@wooorm
Copy link
Member

wooorm commented Jun 30, 2024

I am not sure our projects here should change —— GH made a new format that interferes with references/definitions. We consider those references/definitions too. That’s why they get escaped

@tukusejssirs
Copy link
Author

I am not sure our projects here should change.

@wooorm, well if the package name includes gfm, thus you try to support GitHub Flavored Markdown, I think it is fair to expect your goal is to support all GFM features.

That said, I see that here the GFM spec is only v0.29-gfm from 6 Apr 2019 and it does not include the alerts feature, so you might say you don’t want to add anything outside of the (latest) published spec of GFM which is fine.

GH made a new format that interferes with references/definitions.

Does it interfere? This new feature has a strict format (/^> {0,4}\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](\n> *.*)+$/gm) which could be made an exception to the references/definitions format. Anyway, is [!NOTE] a valid reference/definition format? It could be if one defines such reference, however can it start with an exclamation mark? 🤔 Even if it can, the alerts are so strict about the formatting the alert types, it should be a big issue IMHO. That said, you know the plugin’s codebase better. 😉

@wooorm
Copy link
Member

wooorm commented Jun 30, 2024

As you found out, notes aren’t GFM.
GFM is several syntax extensions to markdown that work everywhere on GitHub.
This isn’t a syntax extension.
This is AST transforms on the HTML.
GH does many things to your content that aren’t GFM.

Does it interfere?
Anyway, is [!NOTE] a valid reference/definition format

Yep, I just showed that: #67 (comment)

The alerts are so strict about the formatting the alert types

They’re loose enough to allow that escaped [. It works, this project makes markdown that works?

@wooorm
Copy link
Member

wooorm commented Jun 30, 2024

You might enjoy this example:

<blockquote>
<p>[!NOTE]
asd</p>
</blockquote>

Note

asd

@tukusejssirs
Copy link
Author

Okay, @wooorm, thanks for your time. 🙏

Indeed it works as expected even with \[!NOTE]. Now I think it might be even better to keep it as is, as it lets references work in all cases.

You might enjoy this example:

When I write Markdown, I prefer not inserting HTML code unless there is a big requirement to do so. However, thanks for sharing this! 🙏


Feel free to close this issue. 😉

@wooorm
Copy link
Member

wooorm commented Jul 10, 2024

ok, closing! 👍

I prefer not inserting HTML code

Right right! No, I meant to show this as it illustrtrates how GH works! They also accept this HTML. They don’t give a hoot about the original markdown of the [!NOTE]!

@wooorm wooorm closed this as completed Jul 10, 2024

This comment has been minimized.

@wooorm wooorm added the 🙅 no/wontfix This is not (enough of) an issue for this project label Jul 10, 2024
@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

3 participants