mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
client/markdown: add tag to show favicon alongside URL
This commit is contained in:
@ -26,6 +26,10 @@
|
|||||||
<td><code>[sjis](´・ω・`)[/sjis]</td>
|
<td><code>[sjis](´・ω・`)[/sjis]</td>
|
||||||
<td>adds SJIS art</td>
|
<td>adds SJIS art</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>[icon]https://youtube.com[/icon]</td>
|
||||||
|
<td>adds the site icon next to the link</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -110,6 +110,15 @@ class StrikeThroughWrapper extends BaseMarkdownWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FaviconWrapper extends BaseMarkdownWrapper {
|
||||||
|
preprocess(text) {
|
||||||
|
return text.replace(
|
||||||
|
/\[icon\]((?:[^\[]|\[(?!\/?icon\]))+)\[\/icon\]/gi,
|
||||||
|
"[]($1) $1"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createRenderer() {
|
function createRenderer() {
|
||||||
function sanitize(str) {
|
function sanitize(str) {
|
||||||
return str.replace(/&<"/g, (m) => {
|
return str.replace(/&<"/g, (m) => {
|
||||||
@ -155,6 +164,7 @@ function formatMarkdown(text) {
|
|||||||
new SpoilersWrapper(),
|
new SpoilersWrapper(),
|
||||||
new SmallWrapper(),
|
new SmallWrapper(),
|
||||||
new StrikeThroughWrapper(),
|
new StrikeThroughWrapper(),
|
||||||
|
new FaviconWrapper(),
|
||||||
];
|
];
|
||||||
for (let wrapper of wrappers) {
|
for (let wrapper of wrappers) {
|
||||||
text = wrapper.preprocess(text);
|
text = wrapper.preprocess(text);
|
||||||
@ -181,6 +191,7 @@ function formatInlineMarkdown(text) {
|
|||||||
new SpoilersWrapper(),
|
new SpoilersWrapper(),
|
||||||
new SmallWrapper(),
|
new SmallWrapper(),
|
||||||
new StrikeThroughWrapper(),
|
new StrikeThroughWrapper(),
|
||||||
|
new FaviconWrapper(),
|
||||||
];
|
];
|
||||||
for (let wrapper of wrappers) {
|
for (let wrapper of wrappers) {
|
||||||
text = wrapper.preprocess(text);
|
text = wrapper.preprocess(text);
|
||||||
|
Reference in New Issue
Block a user