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

Support GitHub style admonitions / alerts / callouts #2486

Open
jhildenbiddle opened this issue Aug 6, 2024 · 1 comment · May be fixed by #2487
Open

Support GitHub style admonitions / alerts / callouts #2486

jhildenbiddle opened this issue Aug 6, 2024 · 1 comment · May be fixed by #2487
Assignees
Milestone

Comments

@jhildenbiddle
Copy link
Member

jhildenbiddle commented Aug 6, 2024

Feature request

Support GFM admonitions / callouts.

Problem or desire

GitHub recently added supports for markdown admonitions / callouts. Docsify should add support for this format so that these elements are rendered as expected in both GitHub and Docsify environments.

GitHub Markdown:

> [!NOTE]  
> Highlights information that users should take into account, even when skimming.

> [!TIP]
> Optional information to help a user be more successful.

> [!IMPORTANT]  
> Crucial information necessary for users to succeed.

> [!WARNING]  
> Critical content demanding immediate user attention due to potential risks.

> [!CAUTION]
> Negative potential consequences of an action.

GitHub Output:

Note

Highlights information that users should take into account, even when skimming.

Tip

Optional information to help a user be more successful.

Important

Crucial information necessary for users to succeed.

Warning

Critical content demanding immediate user attention due to potential risks.

Caution

Negative potential consequences of an action.

Proposal

  1. Render GFM admonitions. Styles do not need to match GFM styles.
  2. Consider deprecating current ?> and !> style helpers in favor of GFM-style blockquote helpers. This will address long-standing issues with multi-line helpers (e.g. Question about "General Tips" #483 and warning blockquotes do not render sub-elements correctly #1588) and poor rendering of these helpers when rendering Markdown outside of Docsify (e.g. GitHub).

Implementation

  • Utilize blockquote compiler instead of paragraph compiler
@jhildenbiddle jhildenbiddle added this to the 5.x milestone Aug 6, 2024
@jhildenbiddle jhildenbiddle self-assigned this Aug 6, 2024
@Koooooo-7
Copy link
Member

Nice and pretty styling solution.

FYI: Add and override the blockquote parser in docsify by marked v13+.

export const blockquoteCompiler = ({ renderer }) =>
  (renderer.blockquote = function ({ tokens }) {
    const body = this.parser.parse(tokens);
    // we could add the GFM admonitions / callouts support here.
    return `<blockquote>${body}</blockquote>`;
  });

@jhildenbiddle jhildenbiddle changed the title Support GitHub style admonitions / callouts Support GitHub style admonitions / alerts / callouts Aug 7, 2024
@jhildenbiddle jhildenbiddle linked a pull request Aug 8, 2024 that will close this issue
6 tasks
@jhildenbiddle jhildenbiddle linked a pull request Aug 8, 2024 that will close this issue
6 tasks
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 a pull request may close this issue.

2 participants