This commit is contained in:
G1org1o
2025-05-23 20:47:20 +02:00
committed by GitHub
2 changed files with 15 additions and 0 deletions

View File

@ -26,6 +26,10 @@
<td><code>[sjis](´・ω・`)[/sjis]</td>
<td>adds SJIS art</td>
</tr>
<tr>
<td><code>[icon]https://youtube.com[/icon]</td>
<td>adds the site icon next to the link</td>
</tr>
</tbody>
</table>

View File

@ -110,6 +110,15 @@ class StrikeThroughWrapper extends BaseMarkdownWrapper {
}
}
class FaviconWrapper extends BaseMarkdownWrapper {
preprocess(text) {
return text.replace(
/\[icon\]((?:[^\[]|\[(?!\/?icon\]))+)\[\/icon\]/gi,
"[![$1](https://www.google.com/s2/favicons?domain=$1)]($1) $1"
);
}
}
function createRenderer() {
function sanitize(str) {
return str.replace(/&<"/g, (m) => {
@ -155,6 +164,7 @@ function formatMarkdown(text) {
new SpoilersWrapper(),
new SmallWrapper(),
new StrikeThroughWrapper(),
new FaviconWrapper(),
];
for (let wrapper of wrappers) {
text = wrapper.preprocess(text);
@ -181,6 +191,7 @@ function formatInlineMarkdown(text) {
new SpoilersWrapper(),
new SmallWrapper(),
new StrikeThroughWrapper(),
new FaviconWrapper(),
];
for (let wrapper of wrappers) {
text = wrapper.preprocess(text);