2 Commits

Author SHA1 Message Date
2ff2378054 Merge cebb9fbdff into ee7e9ef2a3 2025-05-23 20:47:20 +02:00
cebb9fbdff client/markdown: add tag to show favicon alongside URL 2025-04-08 23:39:42 +02:00
3 changed files with 15 additions and 1 deletions

View File

@ -121,7 +121,6 @@
.thumbnail
width: 4em
height: 3em
background-position: 50% 30%
li
margin: 0 0.3em 0.3em 0
display: inline-block

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);