mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-26 21:26:01 -05:00
Fix removeMarkdown stripping inline link text
This commit is contained in:
@@ -74,4 +74,10 @@ describe("removeMarkdown()", () => {
|
||||
test("Strips HTML tags and markdown emphasis", () => {
|
||||
expect(removeMarkdown("<p>Hello **world**!</p>")).toBe("Hello world!");
|
||||
});
|
||||
|
||||
test("Keeps the link text of inline links", () => {
|
||||
expect(
|
||||
removeMarkdown("Check out [the site](https://example.com) today"),
|
||||
).toBe("Check out the site today");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -113,7 +113,7 @@ export function removeMarkdown(value: string) {
|
||||
// Remove images
|
||||
.replace(/!\[(.*?)\][[(].*?[\])]/g, "")
|
||||
// Remove inline links
|
||||
.replace(/\[([^\]]*?)\][[(].*?[\])]/g, "$2")
|
||||
.replace(/\[([^\]]*?)\][[(].*?[\])]/g, "$1")
|
||||
// Remove blockquotes
|
||||
.replace(/^(\n)?\s{0,3}>\s?/gm, "$1")
|
||||
// Remove reference-style links?
|
||||
|
||||
Reference in New Issue
Block a user