Skip to content

Commit 12ec9b0

Browse files
committed
Use CSS class markdown-alert instead of alert
1 parent b0059f5 commit 12ec9b0

File tree

6 files changed

+82
-82
lines changed

6 files changed

+82
-82
lines changed

src/html.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1155,13 +1155,13 @@ where
11551155
NodeValue::Alert(ref alert) => {
11561156
if entering {
11571157
self.cr()?;
1158-
self.output.write_all(b"<div class=\"alert ")?;
1158+
self.output.write_all(b"<div class=\"markdown-alert ")?;
11591159
self.output
11601160
.write_all(alert.alert_type.css_class().as_bytes())?;
11611161
self.output.write_all(b"\"")?;
11621162
self.render_sourcepos(node)?;
11631163
self.output.write_all(b">\n")?;
1164-
self.output.write_all(b"<p class=\"alert-title\">")?;
1164+
self.output.write_all(b"<p class=\"markdown-alert-title\">")?;
11651165
match alert.title {
11661166
Some(ref title) => self.escape(title.as_bytes())?,
11671167
None => {

src/parser/alert.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ impl AlertType {
5252
/// Returns the CSS class to use for an alert type
5353
pub(crate) fn css_class(&self) -> String {
5454
match *self {
55-
AlertType::Note => String::from("alert-note"),
56-
AlertType::Tip => String::from("alert-tip"),
57-
AlertType::Important => String::from("alert-important"),
58-
AlertType::Warning => String::from("alert-warning"),
59-
AlertType::Caution => String::from("alert-caution"),
55+
AlertType::Note => String::from("markdown-alert-note"),
56+
AlertType::Tip => String::from("markdown-alert-tip"),
57+
AlertType::Important => String::from("markdown-alert-important"),
58+
AlertType::Warning => String::from("markdown-alert-warning"),
59+
AlertType::Caution => String::from("markdown-alert-caution"),
6060
}
6161
}
6262
}

src/parser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ pub struct ExtensionOptions<'c> {
434434
/// let mut options = Options::default();
435435
/// options.extension.alerts = true;
436436
/// assert_eq!(markdown_to_html("> [!note]\n> Something of note", &options),
437-
/// "<div class=\"alert alert-note\">\n<p class=\"alert-title\">Note</p>\n<p>Something of note</p>\n</div>\n");
437+
/// "<div class=\"markdown-alert markdown-alert-note\">\n<p class=\"markdown-alert-title\">Note</p>\n<p>Something of note</p>\n</div>\n");
438438
/// ```
439439
#[cfg_attr(feature = "bon", builder(default))]
440440
pub alerts: bool,

src/tests/alerts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ fn alerts() {
66
[extension.alerts],
77
concat!("> [!note]\n", "> Pay attention\n",),
88
concat!(
9-
"<div class=\"alert alert-note\">\n",
10-
"<p class=\"alert-title\">Note</p>\n",
9+
"<div class=\"markdown-alert markdown-alert-note\">\n",
10+
"<p class=\"markdown-alert-title\">Note</p>\n",
1111
"<p>Pay attention</p>\n",
1212
"</div>\n",
1313
),
@@ -20,8 +20,8 @@ fn multiline_alerts() {
2020
[extension.alerts, extension.multiline_block_quotes],
2121
concat!(">>> [!note]\n", "Pay attention\n", ">>>",),
2222
concat!(
23-
"<div class=\"alert alert-note\">\n",
24-
"<p class=\"alert-title\">Note</p>\n",
23+
"<div class=\"markdown-alert markdown-alert-note\">\n",
24+
"<p class=\"markdown-alert-title\">Note</p>\n",
2525
"<p>Pay attention</p>\n",
2626
"</div>\n",
2727
),

src/tests/fixtures/alerts.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ GitHub style alerts look like this:
1111
> [!NOTE]
1212
> Highlights information that users should take into account, even when skimming.
1313
.
14-
<div class="alert alert-note">
15-
<p class="alert-title">Note</p>
14+
<div class="markdown-alert markdown-alert-note">
15+
<p class="markdown-alert-title">Note</p>
1616
<p>Highlights information that users should take into account, even when skimming.</p>
1717
</div>
1818
````````````````````````````````
@@ -24,8 +24,8 @@ the `[!NOTE]`:
2424
> [!NOTE]
2525
> Highlights information that users should take into account, even when skimming.
2626
.
27-
<div class="alert alert-note">
28-
<p class="alert-title">Note</p>
27+
<div class="markdown-alert markdown-alert-note">
28+
<p class="markdown-alert-title">Note</p>
2929
<p>Highlights information that users should take into account, even when skimming.</p>
3030
</div>
3131
````````````````````````````````
@@ -36,8 +36,8 @@ Uppercase isn't required:
3636
> [!note]
3737
> Highlights information that users should take into account, even when skimming.
3838
.
39-
<div class="alert alert-note">
40-
<p class="alert-title">Note</p>
39+
<div class="markdown-alert markdown-alert-note">
40+
<p class="markdown-alert-title">Note</p>
4141
<p>Highlights information that users should take into account, even when skimming.</p>
4242
</div>
4343
````````````````````````````````
@@ -51,8 +51,8 @@ Alerts can contain multiple blocks:
5151
>
5252
> Paragraph two.
5353
.
54-
<div class="alert alert-note">
55-
<p class="alert-title">Note</p>
54+
<div class="markdown-alert markdown-alert-note">
55+
<p class="markdown-alert-title">Note</p>
5656
<p>Highlights information that users should take into account, even when skimming.</p>
5757
<p>Paragraph two.</p>
5858
</div>
@@ -64,8 +64,8 @@ Other kinds of alerts:
6464
> [!TIP]
6565
> Optional information to help a user be more successful.
6666
.
67-
<div class="alert alert-tip">
68-
<p class="alert-title">Tip</p>
67+
<div class="markdown-alert markdown-alert-tip">
68+
<p class="markdown-alert-title">Tip</p>
6969
<p>Optional information to help a user be more successful.</p>
7070
</div>
7171
````````````````````````````````
@@ -74,8 +74,8 @@ Other kinds of alerts:
7474
> [!IMPORTANT]
7575
> Crucial information necessary for users to succeed.
7676
.
77-
<div class="alert alert-important">
78-
<p class="alert-title">Important</p>
77+
<div class="markdown-alert markdown-alert-important">
78+
<p class="markdown-alert-title">Important</p>
7979
<p>Crucial information necessary for users to succeed.</p>
8080
</div>
8181
````````````````````````````````
@@ -84,8 +84,8 @@ Other kinds of alerts:
8484
> [!WARNING]
8585
> Critical content demanding immediate user attention due to potential risks.
8686
.
87-
<div class="alert alert-warning">
88-
<p class="alert-title">Warning</p>
87+
<div class="markdown-alert markdown-alert-warning">
88+
<p class="markdown-alert-title">Warning</p>
8989
<p>Critical content demanding immediate user attention due to potential risks.</p>
9090
</div>
9191
````````````````````````````````
@@ -94,8 +94,8 @@ Other kinds of alerts:
9494
> [!CAUTION]
9595
> Negative potential consequences of an action.
9696
.
97-
<div class="alert alert-caution">
98-
<p class="alert-title">Caution</p>
97+
<div class="markdown-alert markdown-alert-caution">
98+
<p class="markdown-alert-title">Caution</p>
9999
<p>Negative potential consequences of an action.</p>
100100
</div>
101101
````````````````````````````````
@@ -106,8 +106,8 @@ A title can be specified to override the default title:
106106
> [!NOTE] Pay attention
107107
> Highlights information that users should take into account, even when skimming.
108108
.
109-
<div class="alert alert-note">
110-
<p class="alert-title">Pay attention</p>
109+
<div class="markdown-alert markdown-alert-note">
110+
<p class="markdown-alert-title">Pay attention</p>
111111
<p>Highlights information that users should take into account, even when skimming.</p>
112112
</div>
113113
````````````````````````````````
@@ -118,8 +118,8 @@ The title does not process markdown and is escaped:
118118
> [!NOTE] **Pay** attention <script>
119119
> Highlights information that users should take into account, even when skimming.
120120
.
121-
<div class="alert alert-note">
122-
<p class="alert-title">**Pay** attention &lt;script&gt;</p>
121+
<div class="markdown-alert markdown-alert-note">
122+
<p class="markdown-alert-title">**Pay** attention &lt;script&gt;</p>
123123
<p>Highlights information that users should take into account, even when skimming.</p>
124124
</div>
125125
````````````````````````````````
@@ -135,8 +135,8 @@ They work in the same places as a normal blockquote would, such as in a list ite
135135
<ul>
136136
<li>
137137
<p>Item one</p>
138-
<div class="alert alert-note">
139-
<p class="alert-title">Note</p>
138+
<div class="markdown-alert markdown-alert-note">
139+
<p class="markdown-alert-title">Note</p>
140140
<p>Highlights information that users should take into account, even when skimming.</p>
141141
</div>
142142
</li>

0 commit comments

Comments
 (0)