Skip to content

Commit 44899ef

Browse files
Documentation Alerts bug fixing (#2062)
Let's try this again. This makes documentation alerts case-insensitive. This is the easiest solution and is better than requiring all caps, as the latter breaks the alert's title and formatting. Putting HTML into block alerts has extra padding due to empty auto-generated `<p>` elements, planning on fixing whenever I can
1 parent 47c614c commit 44899ef

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

development/docs-template.ejs

-4
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@
162162
font-size: 14px;
163163
display: flex;
164164
}
165-
166-
.alert p:last-child {
167-
padding-bottom: 10px;
168-
}
169165
170166
/* Specific Color Overrides for Each Alert */
171167
.alert.alert-note > p:first-child { color: #4493f8; }

development/render-docs.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ md.block.ruler.before(
4343
state.eMarks[startLine]
4444
);
4545

46-
const match = marker.match(/^\s*>\s*\[!([A-Z]+)]\s*(.*)/);
46+
const match = marker.match(/^\s*>\s*\[!([A-Z]+)]\s*(.*)/i);
4747
if (!match) return false;
4848

4949
const type = match[1].toLowerCase();
@@ -65,7 +65,7 @@ md.block.ruler.before(
6565
tokenTitle.children = [];
6666
state.push("paragraph_close", "p", -1);
6767

68-
// Process all lines inside the blockquote
68+
state.push("paragraph_open", "p", 1);
6969
let nextLine = startLine + 1;
7070
while (nextLine < endLine) {
7171
const nextMarker = state.src.slice(
@@ -77,14 +77,13 @@ md.block.ruler.before(
7777
const lineContent = nextMarker.replace(/^\s*>?\s*/, "").trim();
7878

7979
if (lineContent === "") {
80-
state.push("paragraph_open", "p", 1);
81-
state.push("paragraph_close", "p", -1);
80+
const token = state.push("html_block", "", 0);
81+
token.content = nextLine - 1 == startLine ? "<br/>" : "<br/><br/>";
82+
token.children = [];
8283
} else {
83-
state.push("paragraph_open", "p", 1);
8484
const token = state.push("inline", "", 0);
8585
token.content = lineContent;
8686
token.children = [];
87-
state.push("paragraph_close", "p", -1);
8887
}
8988

9089
nextLine++;
@@ -93,6 +92,7 @@ md.block.ruler.before(
9392
}
9493
}
9594

95+
state.push("paragraph_close", "p", -1);
9696
// Close alert div
9797
const tokenClose = state.push("html_block", "", 0);
9898
tokenClose.content = `</div>`;

0 commit comments

Comments
 (0)