Skip to content

Commit ffd9143

Browse files
Switch markdown alert icons to Font Awesome paths
Co-authored-by: ThisIs-Developer <109382325+ThisIs-Developer@users.noreply.github.com> Agent-Logs-Url: https://github.com/ThisIs-Developer/Markdown-Viewer/sessions/7a7f788a-ac86-476b-afbb-d2cd30792f53
1 parent a89d5f4 commit ffd9143

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

script.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,28 @@ document.addEventListener("DOMContentLoaded", function () {
139139
const GITHUB_ALERT_META = {
140140
note: {
141141
label: "Note",
142-
path: "M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z",
142+
viewBox: "0 0 512 512",
143+
path: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z",
143144
},
144145
tip: {
145146
label: "Tip",
146-
path: "M8 1a4.75 4.75 0 0 0-2.543 8.762.75.75 0 0 1 .343.637v.351c0 .564.302 1.084.79 1.364l.66.378V13a1 1 0 0 0 1 1h.5a1 1 0 0 0 1-1v-.508l.66-.378a1.572 1.572 0 0 0 .79-1.364V10.4a.75.75 0 0 1 .343-.638A4.75 4.75 0 0 0 8 1Zm-1.25 12h2.5v-.138l.915-.522a.572.572 0 0 0 .285-.495V11h-5v.845c0 .203.109.39.285.495l.915.522V13Z",
147+
viewBox: "0 0 384 512",
148+
path: "M297.2 248.9C311.6 228.3 320 203.2 320 176c0-70.7-57.3-128-128-128S64 105.3 64 176c0 27.2 8.4 52.3 22.8 72.9c3.7 5.3 8.1 11.3 12.8 17.7c0 0 0 0 0 0c12.9 17.7 28.3 38.9 39.8 59.8c10.4 19 15.7 38.8 18.3 57.5L109 384c-2.2-12-5.9-23.7-11.8-34.5c-9.9-18-22.2-34.9-34.5-51.8c0 0 0 0 0 0s0 0 0 0c-5.2-7.1-10.4-14.2-15.4-21.4C27.6 247.9 16 213.3 16 176C16 78.8 94.8 0 192 0s176 78.8 176 176c0 37.3-11.6 71.9-31.4 100.3c-5 7.2-10.2 14.3-15.4 21.4c0 0 0 0 0 0s0 0 0 0c-12.3 16.8-24.6 33.7-34.5 51.8c-5.9 10.8-9.6 22.5-11.8 34.5l-48.6 0c2.6-18.7 7.9-38.6 18.3-57.5c11.5-20.9 26.9-42.1 39.8-59.8c0 0 0 0 0 0s0 0 0 0s0 0 0 0c4.7-6.4 9-12.4 12.7-17.7zM192 128c-26.5 0-48 21.5-48 48c0 8.8-7.2 16-16 16s-16-7.2-16-16c0-44.2 35.8-80 80-80c8.8 0 16 7.2 16 16s-7.2 16-16 16zm0 384c-44.2 0-80-35.8-80-80l0-16 160 0 0 16c0 44.2-35.8 80-80 80z",
147149
},
148150
important: {
149151
label: "Important",
150-
path: "M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16ZM7.25 4.75a.75.75 0 0 1 1.5 0v3.5a.75.75 0 0 1-1.5 0v-3.5Zm.75 7.25a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z",
152+
viewBox: "0 0 512 512",
153+
path: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z",
151154
},
152155
warning: {
153156
label: "Warning",
154-
path: "M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",
157+
viewBox: "0 0 512 512",
158+
path: "M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480L40 480c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24l0 112c0 13.3 10.7 24 24 24s24-10.7 24-24l0-112c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z",
155159
},
156160
caution: {
157161
label: "Caution",
158-
path: "M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16Zm2.47-10.53a.75.75 0 0 1 0 1.06L9.06 8l1.41 1.47a.75.75 0 1 1-1.08 1.04L8 9.08l-1.39 1.43a.75.75 0 0 1-1.08-1.04L6.94 8 5.53 6.53a.75.75 0 0 1 1.08-1.04L8 6.92l1.39-1.43a.75.75 0 0 1 1.08 0Z",
162+
viewBox: "0 0 512 512",
163+
path: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z",
159164
},
160165
};
161166
const GITHUB_ALERT_MARKER_REGEX = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\](?:\s+|$)/i;
@@ -183,14 +188,14 @@ document.addEventListener("DOMContentLoaded", function () {
183188

184189
const title = document.createElement("p");
185190
title.className = "markdown-alert-title";
186-
const alertMeta = GITHUB_ALERT_META[alertType] || { label: markerMatch[1], path: "" };
191+
const alertMeta = GITHUB_ALERT_META[alertType] || { label: markerMatch[1], path: "", viewBox: "0 0 16 16" };
187192
const icon = document.createElement("span");
188193
icon.className = "markdown-alert-icon";
189194
icon.setAttribute("aria-hidden", "true");
190195

191196
if (alertMeta.path) {
192197
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
193-
svg.setAttribute("viewBox", "0 0 16 16");
198+
svg.setAttribute("viewBox", alertMeta.viewBox || "0 0 16 16");
194199
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
195200
path.setAttribute("d", alertMeta.path);
196201
svg.appendChild(path);

0 commit comments

Comments
 (0)