Skip to content

Commit 3db0648

Browse files
committed
Strip images with a space between alt text and URL
1 parent 94873c0 commit 3db0648

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

strip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var (
2020
setextHeaderReg = regexp.MustCompile(`^[=\-]{2,}\s*$`)
2121
footnotesReg = regexp.MustCompile(`\[\^.+?\](\: .*?$)?`)
2222
footnotes2Reg = regexp.MustCompile(`\s{0,2}\[.*?\]: .*?$`)
23-
imagesReg = regexp.MustCompile(`\!\[.*?\][\[\(].*?[\]\)]`)
23+
imagesReg = regexp.MustCompile(`\!\[.*?\]\s?[\[\(].*?[\]\)]`)
2424
linksReg = regexp.MustCompile(`\[(.*?)\][\[\(].*?[\]\)]`)
2525
blockquoteReg = regexp.MustCompile(`>\s*`)
2626
refLinkReg = regexp.MustCompile(`^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$`)

strip_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,10 @@ You can even share code stuff.`
9191
if res := Strip(in); res != out {
9292
t.Errorf("Original:\n\n%s\n\nGot:\n\n%s", in, res)
9393
}
94+
95+
in = "![Some image] (https://write.as/favicon.ico)"
96+
out = ""
97+
if res := Strip(in); res != out {
98+
t.Errorf("Original:\n\n%s\n\nGot:\n\n%s", in, res)
99+
}
94100
}

0 commit comments

Comments
 (0)