Skip to content

Add support for Alerts #67

Closed
Closed

Description

@tukusejssirs

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. 😉

Activity

  1. added
    👋 phase/newPost is being triaged automatically
    🤞 phase/openPost is being triaged manually
    and removed
    👋 phase/newPost is being triaged automatically
    on Jun 29, 2024
  2. remcohaszing commented on Jun 29, 2024

    @remcohaszing
    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.

  3. tukusejssirs commented on Jun 29, 2024

    @tukusejssirs
    Author

    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.

  4. wooorm commented on Jun 30, 2024

    @wooorm
    Member
    > [!NOTE]
    Some note
    
    [!note]: https://example.com

    Yields:

    !NOTE
    Some note

  5. wooorm commented on Jun 30, 2024

    @wooorm
    Member

    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

  6. tukusejssirs commented on Jun 30, 2024

    @tukusejssirs
    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. 😉

  7. wooorm commented on Jun 30, 2024

    @wooorm
    Member

    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?

  8. wooorm commented on Jun 30, 2024

    @wooorm
    Member

    You might enjoy this example:

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

    Note

    asd

  9. tukusejssirs commented on Jun 30, 2024

    @tukusejssirs
    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. 😉

  10. wooorm commented on Jul 10, 2024

    @wooorm
    Member

    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]!

  11. github-actions commented on Jul 10, 2024

    @github-actions
  12. added
    👎 phase/noPost cannot or will not be acted on
    and removed
    🤞 phase/openPost is being triaged manually
    on Jul 10, 2024
  13. theking2 commented on Jan 10, 2026

    @theking2

    both

    > [!NOTE]
    this is informational

    and

    > [!NOTE]
    > this is informational

    yield

    Note

    this is informational

    at least here

  14. wooorm commented on Jan 18, 2026

    @wooorm
    Member

    yep, that’s how lazy blockquote lines work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🙅 no/wontfixThis is not (enough of) an issue for this project

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions