@@ -40,6 +40,142 @@ Support [GitHub-style alerts](https://github.com/orgs/community/discussions/1692
4040> [ !CAUTION]
4141> Negative potential consequences of an action.
4242
43+ ## Usage
44+
45+ ``` bash
46+ npm i markdown-it-github-alerts
47+ ```
48+
49+ ``` js
50+ import MarkdownIt from ' markdown-it'
51+ import MarkdownItGitHubAlerts from ' markdown-it-github-alerts'
52+
53+ const md = MarkdownIt ()
54+
55+ md .use (MarkdownItGitHubAlerts)
56+
57+ const html = md .render (/* ... */ )
58+ ```
59+
60+ ## Functionality
61+
62+ This plugin transforms the following markdown:
63+
64+ ``` markdown
65+ > [!NOTE]
66+ > Highlights information that users should take into account, even when skimming.
67+ ```
68+
69+ to the following HTML:
70+
71+ ``` html
72+ <div class =" markdown-alert markdown-alert-note" >
73+ <p class =" markdown-alert-title" dir =" auto" ><!-- svg icon--> Note</p ><p >
74+ Highlights information that users should take into account, even when skimming.</p >
75+ </div >
76+ ```
77+
78+ Which is compatible with the GitHub's output.
79+
80+ ### Styling
81+
82+ You can write your custom styles for your alerts.
83+
84+ The following CSS is extracted from GitHub for your reference.
85+
86+ ``` css
87+ :root {
88+ --color-note : #0969da ;
89+ --color-tip : #1a7f37 ;
90+ --color-warning : #9a6700 ;
91+ --color-severe : #bc4c00 ;
92+ --color-caution : #d1242f ;
93+ --color-important : #8250df ;
94+ }
95+
96+ @media (prefers-color-scheme: dark) {
97+ :root {
98+ --color-note : #2f81f7 ;
99+ --color-tip : #3fb950 ;
100+ --color-warning : #d29922 ;
101+ --color-severe : #db6d28 ;
102+ --color-caution : #f85149 ;
103+ --color-important : #a371f7 ;
104+ }
105+ }
106+
107+ .markdown-alert {
108+ padding : 0.5rem 1rem ;
109+ margin-bottom : 16px ;
110+ color : inherit ;
111+ border-left : .25em solid #888 ;
112+ }
113+
114+ .markdown-alert > :first-child {
115+ margin-top : 0
116+ }
117+
118+ .markdown-alert > :last-child {
119+ margin-bottom : 0
120+ }
121+
122+ .markdown-alert .markdown-alert-title {
123+ display : flex ;
124+ font-weight : 500 ;
125+ align-items : center ;
126+ line-height : 1
127+ }
128+
129+ .markdown-alert .markdown-alert-title .octicon {
130+ margin-right : 0.5rem ;
131+ display : inline-block ;
132+ overflow : visible !important ;
133+ vertical-align : text-bottom ;
134+ fill : currentColor ;
135+ }
136+
137+ .markdown-alert.markdown-alert-note {
138+ border-left-color : var (--color-note );
139+ }
140+
141+ .markdown-alert.markdown-alert-note .markdown-alert-title {
142+ color : var (--color-note );
143+ }
144+
145+ .markdown-alert.markdown-alert-important {
146+ border-left-color : var (--color-important );
147+ }
148+
149+ .markdown-alert.markdown-alert-important .markdown-alert-title {
150+ color : var (--color-important );
151+ }
152+
153+ .markdown-alert.markdown-alert-warning {
154+ border-left-color : var (--color-warning );
155+ }
156+
157+ .markdown-alert.markdown-alert-warning .markdown-alert-title {
158+ color : var (--color-warning );
159+ }
160+
161+ .markdown-alert.markdown-alert-tip {
162+ border-left-color : var (--color-tip );
163+ }
164+
165+ .markdown-alert.markdown-alert-tip .markdown-alert-title {
166+ color : var (--color-tip );
167+ }
168+
169+ .markdown-alert.markdown-alert-caution {
170+ border-left-color : var (--color-caution );
171+ }
172+
173+ .markdown-alert.markdown-alert-caution .markdown-alert-title {
174+ color : var (--color-caution );
175+ }
176+ ```
177+
178+
43179## Sponsors
44180
45181<p align =" center " >
0 commit comments