pantsdown 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils.ts CHANGED
@@ -9,158 +9,196 @@ const escapeReplace = new RegExp(escapeTest.source, "g");
9
9
  const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
10
10
  const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
11
11
  const escapeReplacements: Record<string, string> = {
12
- "&": "&amp;",
13
- "<": "&lt;",
14
- ">": "&gt;",
15
- '"': "&quot;",
16
- "'": "&#39;",
12
+ "&": "&amp;",
13
+ "<": "&lt;",
14
+ ">": "&gt;",
15
+ '"': "&quot;",
16
+ "'": "&#39;",
17
17
  };
18
18
  const getEscapeReplacement = (ch: string) => escapeReplacements[ch]!;
19
19
 
20
20
  // look into using Bun's Bun.escapeHTML()
21
21
  // https://bun.sh/docs/api/utils#bun-escapehtml
22
22
  export function escape(html: string, encode?: boolean) {
23
- if (encode) {
24
- if (escapeTest.test(html)) {
25
- return html.replace(escapeReplace, getEscapeReplacement);
26
- }
27
- } else {
28
- if (escapeTestNoEncode.test(html)) {
29
- return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
30
- }
31
- }
32
-
33
- return html;
23
+ if (encode) {
24
+ if (escapeTest.test(html)) {
25
+ return html.replace(escapeReplace, getEscapeReplacement);
26
+ }
27
+ } else {
28
+ if (escapeTestNoEncode.test(html)) {
29
+ return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
30
+ }
31
+ }
32
+
33
+ return html;
34
34
  }
35
35
 
36
36
  export function getHtmlElementText(html: string) {
37
- try {
38
- const parser = new DOMParser();
39
- const doc = parser.parseFromString(html, "text/html");
40
- // eslint-disable-next-line
41
- if (!doc.body) throw Error("Invalid HTML");
42
- const element = doc.body.firstChild as HTMLElement;
43
- // eslint-disable-next-line
44
- if (!element) throw Error("No valid element found");
45
- return element.textContent ?? html;
46
- } catch (_) {
47
- return html;
48
- }
37
+ try {
38
+ const parser = new DOMParser();
39
+ const doc = parser.parseFromString(html, "text/html");
40
+ // eslint-disable-next-line
41
+ if (!doc.body) throw Error("Invalid HTML");
42
+ const element = doc.body.firstChild as HTMLElement;
43
+ // eslint-disable-next-line
44
+ if (!element) throw Error("No valid element found");
45
+ return element.textContent || html;
46
+ } catch (_) {
47
+ return html;
48
+ }
49
49
  }
50
50
 
51
51
  export function injectHtmlAttributes(html: string, attrs: HTMLAttrs, sourceMap?: SourceMap) {
52
- if (sourceMap) {
53
- attrs.push(["line-start", String(sourceMap[0])]);
54
- attrs.push(["line-end", String(sourceMap[1])]);
55
- }
56
-
57
- if (!attrs.length) return html;
58
-
59
- const closingBracket = /[a-zA-Z0-9\/"]>/;
60
- const match = closingBracket.exec(html);
61
- if (match) {
62
- let htmlAttrs = "";
63
- attrs.forEach((atrr) => (htmlAttrs += ` ${atrr[0]}="${atrr[1]}"`));
64
- const sliceIdx = match.index + (match[0] === "/>" ? -1 : 1);
65
- return html.slice(0, sliceIdx) + htmlAttrs + html.slice(sliceIdx);
66
- }
67
- return html;
52
+ if (sourceMap) {
53
+ attrs.push(["line-start", String(sourceMap[0])]);
54
+ attrs.push(["line-end", String(sourceMap[1])]);
55
+ }
56
+
57
+ if (!attrs.length) return html;
58
+
59
+ const closingBracket = /[a-zA-Z0-9\/"]>/;
60
+ const match = closingBracket.exec(html);
61
+ if (match) {
62
+ let htmlAttrs = "";
63
+ attrs.forEach((atrr) => (htmlAttrs += ` ${atrr[0]}="${atrr[1]}"`));
64
+ const sliceIdx = match.index + (match[0] === "/>" ? -1 : 1);
65
+ return html.slice(0, sliceIdx) + htmlAttrs + html.slice(sliceIdx);
66
+ }
67
+ return html;
68
68
  }
69
69
 
70
70
  export function fixHtmlLocalImageHref(
71
- html: string,
72
- relativeImageUrlPrefix: string | undefined,
71
+ html: string,
72
+ relativeImageUrlPrefix: string | undefined,
73
73
  ): string {
74
- return relativeImageUrlPrefix
75
- ? html.replace(
76
- /<img\s+([^>]*?)src\s*=\s*(["'])([^>'"]+?)\2([^>]*)>/gm,
77
- (_m, g1, _g2, g3: string, g4) => {
78
- const href = fixLocalImageHref(g3, relativeImageUrlPrefix);
79
- return `<img ${g1}src="${href}"${g4}>`;
80
- },
81
- )
82
- : html;
74
+ return relativeImageUrlPrefix
75
+ ? html.replace(
76
+ /<img\s+([^>]*?)src\s*=\s*(["'])([^>'"]+?)\2([^>]*)>/gm,
77
+ (_m, g1, _g2, g3: string, g4) => {
78
+ const href = fixLocalImageHref(g3, relativeImageUrlPrefix);
79
+ return `<img ${g1}src="${href}"${g4}>`;
80
+ },
81
+ )
82
+ : html;
83
+ }
84
+
85
+ /**
86
+ * Add GitHub-style inline styles to images with dimension attributes.
87
+ * - If `height` or `width` is specified: adds `max-width: 100%`
88
+ * - If `height` is specified: also adds `height: auto; max-height: {height}`
89
+ */
90
+ export function addGithubImageStyles(html: string): string {
91
+ return html.replace(/<img\s+([^>]*)>/gi, (_match, attrs: string) => {
92
+ const heightMatch = /height\s*=\s*["']?(\d+(?:px)?)["']?/i.exec(attrs);
93
+ const widthMatch = /width\s*=\s*["']?(\d+(?:px)?)["']?/i.exec(attrs);
94
+
95
+ if (!heightMatch && !widthMatch) return _match;
96
+
97
+ // Build style string matching GitHub's behavior
98
+ const styles: string[] = ["max-width: 100%"];
99
+ if (heightMatch?.[1]) {
100
+ const value = heightMatch[1].endsWith("px") ? heightMatch[1] : `${heightMatch[1]}px`;
101
+ styles.push("height: auto", `max-height: ${value}`);
102
+ }
103
+
104
+ // Check for existing style attribute
105
+ const styleMatch = /style\s*=\s*["']([^"']*)["']/i.exec(attrs);
106
+ let newAttrs = attrs;
107
+
108
+ if (styleMatch?.[1]) {
109
+ // Append to existing style
110
+ const existingStyle = styleMatch[1].trim();
111
+ const separator = existingStyle.endsWith(";") ? " " : "; ";
112
+ const newStyle = existingStyle + separator + styles.join("; ");
113
+ newAttrs = attrs.replace(styleMatch[0], `style="${newStyle}"`);
114
+ } else {
115
+ // Add new style attribute
116
+ newAttrs = attrs + ` style="${styles.join("; ")}"`;
117
+ }
118
+
119
+ return `<img ${newAttrs}>`;
120
+ });
83
121
  }
84
122
 
85
123
  export function fixLocalImageHref(
86
- href: string,
87
- relativeImageUrlPrefix: string | undefined,
124
+ href: string,
125
+ relativeImageUrlPrefix: string | undefined,
88
126
  ): string {
89
- if (!relativeImageUrlPrefix) return href;
90
-
91
- const reIsAbsolute = /^[\w+]+:\/\//;
92
- const dummyUrl = "http://__dummy__";
93
- const dummyBaseUrl = new URL(relativeImageUrlPrefix, dummyUrl);
94
- const dummyUrlLength = dummyUrl.length + (relativeImageUrlPrefix.startsWith("/") ? 0 : 1);
95
-
96
- if (reIsAbsolute.test(href)) {
97
- // the URL is absolute, do not touch it
98
- return href;
99
- }
100
-
101
- if (href.startsWith("/")) {
102
- // the URL is from root
103
- return relativeImageUrlPrefix + href.slice(1);
104
- }
105
-
106
- try {
107
- const temp = new URL(href, dummyBaseUrl).href;
108
- return temp.slice(dummyUrlLength);
109
- } catch (_) {
110
- return href;
111
- }
127
+ if (!relativeImageUrlPrefix) return href;
128
+
129
+ const reIsAbsolute = /^[\w+]+:\/\//;
130
+ const dummyUrl = "http://__dummy__";
131
+ const dummyBaseUrl = new URL(relativeImageUrlPrefix, dummyUrl);
132
+ const dummyUrlLength = dummyUrl.length + (relativeImageUrlPrefix.startsWith("/") ? 0 : 1);
133
+
134
+ if (reIsAbsolute.test(href)) {
135
+ // the URL is absolute, do not touch it
136
+ return href;
137
+ }
138
+
139
+ if (href.startsWith("/")) {
140
+ // the URL is from root
141
+ return relativeImageUrlPrefix + href.slice(1);
142
+ }
143
+
144
+ try {
145
+ const temp = new URL(href, dummyBaseUrl).href;
146
+ return temp.slice(dummyUrlLength);
147
+ } catch (_) {
148
+ return href;
149
+ }
112
150
  }
113
151
 
114
152
  export function cleanUrl(href: string) {
115
- try {
116
- href = encodeURI(href).replace(/%25/g, "%");
117
- } catch (_) {
118
- return null;
119
- }
120
- return href;
153
+ try {
154
+ href = encodeURI(href).replace(/%25/g, "%");
155
+ } catch (_) {
156
+ return null;
157
+ }
158
+ return href;
121
159
  }
122
160
 
123
161
  export const noopTest = { exec: () => null };
124
162
 
125
163
  export function splitCells(tableRow: string, count?: number) {
126
- // ensure that every cell-delimiting pipe has a space
127
- // before it to distinguish it from an escaped pipe
128
- const row = tableRow.replace(/\|/g, (_match, offset: number, str: string) => {
129
- let escaped = false;
130
- let curr = offset;
131
- while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
132
- if (escaped) {
133
- // odd number of slashes means | is escaped
134
- // so we leave it alone
135
- return "|";
136
- } else {
137
- // add space before unescaped |
138
- return " |";
139
- }
140
- }),
141
- cells = row.split(/ \|/);
142
-
143
- // First/last cell in a row cannot be empty if it has no leading/trailing pipe
144
- if (!cells[0]?.trim()) {
145
- cells.shift();
146
- }
147
- if (cells.length > 0 && !cells[cells.length - 1]?.trim()) {
148
- cells.pop();
149
- }
150
-
151
- if (count) {
152
- if (cells.length > count) {
153
- cells.splice(count);
154
- } else {
155
- while (cells.length < count) cells.push("");
156
- }
157
- }
158
-
159
- for (let i = 0, len = cells.length; i < len; i++) {
160
- // leading or trailing whitespace is ignored per the gfm spec
161
- cells[i] = cells[i]!.trim().replace(/\\\|/g, "|");
162
- }
163
- return cells;
164
+ // ensure that every cell-delimiting pipe has a space
165
+ // before it to distinguish it from an escaped pipe
166
+ const row = tableRow.replace(/\|/g, (_match, offset: number, str: string) => {
167
+ let escaped = false;
168
+ let curr = offset;
169
+ while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
170
+ if (escaped) {
171
+ // odd number of slashes means | is escaped
172
+ // so we leave it alone
173
+ return "|";
174
+ } else {
175
+ // add space before unescaped |
176
+ return " |";
177
+ }
178
+ }),
179
+ cells = row.split(/ \|/);
180
+
181
+ // First/last cell in a row cannot be empty if it has no leading/trailing pipe
182
+ if (!cells[0]?.trim()) {
183
+ cells.shift();
184
+ }
185
+ if (cells.length > 0 && !cells[cells.length - 1]?.trim()) {
186
+ cells.pop();
187
+ }
188
+
189
+ if (count) {
190
+ if (cells.length > count) {
191
+ cells.splice(count);
192
+ } else {
193
+ while (cells.length < count) cells.push("");
194
+ }
195
+ }
196
+
197
+ for (let i = 0, len = cells.length; i < len; i++) {
198
+ // leading or trailing whitespace is ignored per the gfm spec
199
+ cells[i] = cells[i]!.trim().replace(/\\\|/g, "|");
200
+ }
201
+ return cells;
164
202
  }
165
203
 
166
204
  /**
@@ -172,138 +210,138 @@ export function splitCells(tableRow: string, count?: number) {
172
210
  * @param invert Remove suffix of non-c chars instead. Default falsey.
173
211
  */
174
212
  export function rtrim(str: string, c: string, invert?: boolean) {
175
- const l = str.length;
176
- if (l === 0) {
177
- return "";
178
- }
179
-
180
- // Length of suffix matching the invert condition.
181
- let suffLen = 0;
182
-
183
- // Step left until we fail to match the invert condition.
184
- while (suffLen < l) {
185
- const currChar = str.charAt(l - suffLen - 1);
186
- if (currChar === c && !invert) {
187
- suffLen++;
188
- } else if (currChar !== c && invert) {
189
- suffLen++;
190
- } else {
191
- break;
192
- }
193
- }
194
-
195
- return str.slice(0, l - suffLen);
213
+ const l = str.length;
214
+ if (l === 0) {
215
+ return "";
216
+ }
217
+
218
+ // Length of suffix matching the invert condition.
219
+ let suffLen = 0;
220
+
221
+ // Step left until we fail to match the invert condition.
222
+ while (suffLen < l) {
223
+ const currChar = str.charAt(l - suffLen - 1);
224
+ if (currChar === c && !invert) {
225
+ suffLen++;
226
+ } else if (currChar !== c && invert) {
227
+ suffLen++;
228
+ } else {
229
+ break;
230
+ }
231
+ }
232
+
233
+ return str.slice(0, l - suffLen);
196
234
  }
197
235
 
198
236
  export function findClosingBracket(str: string, b: string) {
199
- if (!b[1] || !str.includes(b[1])) {
200
- return -1;
201
- }
202
-
203
- let level = 0;
204
- for (let i = 0, len = str.length; i < len; i++) {
205
- if (str[i] === "\\") {
206
- i++;
207
- } else if (str[i] === b[0]) {
208
- level++;
209
- } else if (str[i] === b[1]) {
210
- level--;
211
- if (level < 0) {
212
- return i;
213
- }
214
- }
215
- }
216
- return -1;
237
+ if (!b[1] || !str.includes(b[1])) {
238
+ return -1;
239
+ }
240
+
241
+ let level = 0;
242
+ for (let i = 0, len = str.length; i < len; i++) {
243
+ if (str[i] === "\\") {
244
+ i++;
245
+ } else if (str[i] === b[0]) {
246
+ level++;
247
+ } else if (str[i] === b[1]) {
248
+ level--;
249
+ if (level < 0) {
250
+ return i;
251
+ }
252
+ }
253
+ }
254
+ return -1;
217
255
  }
218
256
 
219
257
  export function outputLink(
220
- cap: string[],
221
- link: Pick<Tokens["Link"], "href" | "title">,
222
- raw: string,
223
- lexer: Lexer,
258
+ cap: string[],
259
+ link: Pick<Tokens["Link"], "href" | "title">,
260
+ raw: string,
261
+ lexer: Lexer,
224
262
  ): Tokens["Link"] | Tokens["Image"] {
225
- const href = link.href;
226
- const title = link.title ? escape(link.title) : null;
227
- const text = cap[1]?.replace(/\\([\[\]])/g, "$1") ?? "";
228
-
229
- if (cap[0]?.charAt(0) !== "!") {
230
- lexer.state.inLink = true;
231
- const token: Tokens["Link"] = {
232
- type: "link",
233
- raw,
234
- href,
235
- title,
236
- text,
237
- tokens: lexer.inlineTokens(text),
238
- };
239
- lexer.state.inLink = false;
240
- return token;
241
- }
242
- return {
243
- type: "image",
244
- raw,
245
- href,
246
- title,
247
- text: escape(text),
248
- };
263
+ const href = link.href;
264
+ const title = link.title ? escape(link.title) : null;
265
+ const text = cap[1]?.replace(/\\([\[\]])/g, "$1") ?? "";
266
+
267
+ if (cap[0]?.charAt(0) !== "!") {
268
+ lexer.state.inLink = true;
269
+ const token: Tokens["Link"] = {
270
+ type: "link",
271
+ raw,
272
+ href,
273
+ title,
274
+ text,
275
+ tokens: lexer.inlineTokens(text),
276
+ };
277
+ lexer.state.inLink = false;
278
+ return token;
279
+ }
280
+ return {
281
+ type: "image",
282
+ raw,
283
+ href,
284
+ title,
285
+ text: escape(text),
286
+ };
249
287
  }
250
288
 
251
289
  export function indentCodeCompensation(raw: string, text: string) {
252
- const matchIndentToCode = /^(\s+)(?:```)/.exec(raw);
290
+ const matchIndentToCode = /^(\s+)(?:```)/.exec(raw);
253
291
 
254
- if (matchIndentToCode === null) {
255
- return text;
256
- }
292
+ if (matchIndentToCode === null) {
293
+ return text;
294
+ }
257
295
 
258
- const indentToCode = matchIndentToCode[1];
296
+ const indentToCode = matchIndentToCode[1];
259
297
 
260
- return text
261
- .split("\n")
262
- .map((node) => {
263
- const matchIndentInNode = /^\s+/.exec(node);
264
- if (matchIndentInNode === null) {
265
- return node;
266
- }
298
+ return text
299
+ .split("\n")
300
+ .map((node) => {
301
+ const matchIndentInNode = /^\s+/.exec(node);
302
+ if (matchIndentInNode === null) {
303
+ return node;
304
+ }
267
305
 
268
- const [indentInNode] = matchIndentInNode;
306
+ const [indentInNode] = matchIndentInNode;
269
307
 
270
- if (indentToCode && indentInNode.length >= indentToCode.length) {
271
- return node.slice(indentToCode.length);
272
- }
308
+ if (indentToCode && indentInNode.length >= indentToCode.length) {
309
+ return node.slice(indentToCode.length);
310
+ }
273
311
 
274
- return node;
275
- })
276
- .join("\n");
312
+ return node;
313
+ })
314
+ .join("\n");
277
315
  }
278
316
 
279
317
  function makeAlertRegex(type: string) {
280
- return new RegExp(`^(?:\\[\\!${type.toUpperCase()}\\]|[\\*]{2}${type}[\\*]{2})[\s]*?\n?`);
318
+ return new RegExp(`^(?:\\[\\!${type.toUpperCase()}\\]|[\\*]{2}${type}[\\*]{2})[\s]*?\n?`);
281
319
  }
282
320
 
283
321
  export const ALERTS = [
284
- {
285
- variant: "Note",
286
- regex: makeAlertRegex("Note"),
287
- icon: '<svg class="octicon octicon-info" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="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"></path></svg>',
288
- },
289
- {
290
- variant: "Important",
291
- regex: makeAlertRegex("Important"),
292
- icon: '<svg class="octicon octicon-report" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',
293
- },
294
- {
295
- variant: "Warning",
296
- regex: makeAlertRegex("Warning"),
297
- icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="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"></path></svg>',
298
- },
299
- {
300
- variant: "Tip",
301
- regex: makeAlertRegex("Tip"),
302
- icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"/></svg>',
303
- },
304
- {
305
- variant: "Caution",
306
- regex: makeAlertRegex("Caution"),
307
- icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"/></svg>',
308
- },
322
+ {
323
+ variant: "Note",
324
+ regex: makeAlertRegex("Note"),
325
+ icon: '<svg class="octicon octicon-info" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="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"></path></svg>',
326
+ },
327
+ {
328
+ variant: "Important",
329
+ regex: makeAlertRegex("Important"),
330
+ icon: '<svg class="octicon octicon-report" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>',
331
+ },
332
+ {
333
+ variant: "Warning",
334
+ regex: makeAlertRegex("Warning"),
335
+ icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="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"></path></svg>',
336
+ },
337
+ {
338
+ variant: "Tip",
339
+ regex: makeAlertRegex("Tip"),
340
+ icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"/></svg>',
341
+ },
342
+ {
343
+ variant: "Caution",
344
+ regex: makeAlertRegex("Caution"),
345
+ icon: '<svg class="octicon octicon-alert" style="margin-right: 0.5rem;" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path d="M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"/></svg>',
346
+ },
309
347
  ];
package/tsconfig.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
2
3
  "compilerOptions": {
3
4
  "lib": ["ESNext"],
4
5
  "module": "ESNext",
5
6
  "target": "ESNext",
7
+ "types": ["bun"],
6
8
  "moduleResolution": "Bundler",
7
9
  "moduleDetection": "force",
8
10
  "allowImportingTsExtensions": true,
9
11
  "noEmit": true,
10
12
  "composite": true,
11
13
  "strict": true,
12
- "downlevelIteration": true,
13
14
  "skipLibCheck": true,
14
15
  "allowSyntheticDefaultImports": true,
15
16
  "forceConsistentCasingInFileNames": true,
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- .github/dependabot.yml
@@ -1,4 +0,0 @@
1
- // TODO: I'm not so sure about this, come back to this
2
- // once Bun has official css loader
3
- const styles: string;
4
- export default styles;