1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// SPDX-License-Identifier: 0BSD
import "npm:linkifyjs";
import "npm:linkify-plugin-hashtag";
import "npm:linkify-plugin-mention";
import linkify from "npm:linkify-html";
export const linkifyReadme = (html: string) =>
linkify(html, {
ignoreTags: ["head", "script", "style", "code"],
rel: "nofollow noreferrer noopener",
formatHref: {
mention(input) {
input = input.substring(1);
if (input.includes("/")) {
const valURL = new URL(`https://www.val.town/v/${input}`);
return valURL.href;
}
const profileURL = new URL(`https://www.val.town/u/${input}`);
return profileURL.href;
},
hashtag(input) {
const searchURL = new URL("https://www.val.town/search");
searchURL.searchParams.set("q", input);
return searchURL.href;
},
},
});
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 6, 2024