From 79a7ca750ee4c8839b8777413c232ff2fcb60836 Mon Sep 17 00:00:00 2001 From: Marcel van der Boom Date: Mon, 3 Dec 2018 12:08:02 +0100 Subject: [PATCH] Require hashtags to have a space before them This improves rendering in a number of situations: - it keeps anchor tags working - it gives the user some control for not linking, for example in code blocks. Con: hashTags at the beginning of a line without a space won't get linked. Workaround related to issues #42 and #6 and #33 --- postrender.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postrender.go b/postrender.go index f739bdc..d2af941 100644 --- a/postrender.go +++ b/postrender.go @@ -21,7 +21,7 @@ var ( endBlockReg = regexp.MustCompile("\n") youtubeReg = regexp.MustCompile("(https?://www.youtube.com/embed/[a-zA-Z0-9\\-_]+)(\\?[^\t\n\f\r \"']+)?") titleElementReg = regexp.MustCompile("") - hashtagReg = regexp.MustCompile(`#([\p{L}\p{M}\d]+)`) + hashtagReg = regexp.MustCompile(` #([\p{L}\p{M}\d]+)`) markeddownReg = regexp.MustCompile("

(.+)

") ) @@ -36,7 +36,7 @@ func (p *Post) formatContent(c *Collection, isOwner bool) { // URL, so we rely on p.Tags as the final word on whether or not to link // a tag. for _, t := range p.Tags { - if string(b) == "#"+t { + if string(b) == " #"+t { return bytes.Replace(b, []byte("#"+t), []byte("#"+t+""), -1) } }