Problem: tags are not parsed in the backend
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Solution: replace tag with markdown links
This commit is contained in:
parent
8fa7d4170f
commit
569bef3226
|
@ -24,7 +24,7 @@ Plugin.prototype.init = function (md) {
|
||||||
export function tagParser(id, state, silent) {
|
export function tagParser(id, state, silent) {
|
||||||
let input = state.src.slice(state.pos);
|
let input = state.src.slice(state.pos);
|
||||||
|
|
||||||
const match = /^#[^ ]+/.exec(input)
|
const match = /^#\S+/.exec(input)
|
||||||
if (!match) {
|
if (!match) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
14
main.go
14
main.go
|
@ -922,11 +922,7 @@ func (h *indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderLinks(pageText string, edit bool) string {
|
func renderLinks(pageText string, edit bool) string {
|
||||||
hrefRE, err := regexp.Compile(`#?\[\[\s*([^\]]+)\s*\]\]`)
|
hrefRE := regexp.MustCompile(`#?\[\[\s*([^\]]+)\s*\]\]`)
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
pageText = hrefRE.ReplaceAllStringFunc(pageText, func(s string) string {
|
pageText = hrefRE.ReplaceAllStringFunc(pageText, func(s string) string {
|
||||||
tag := false
|
tag := false
|
||||||
if s[0] == '#' {
|
if s[0] == '#' {
|
||||||
|
@ -955,6 +951,14 @@ func renderLinks(pageText string, edit bool) string {
|
||||||
|
|
||||||
return fmt.Sprintf("[%s](/%s%s)", s, editPart, cleanNameURL(s))
|
return fmt.Sprintf("[%s](/%s%s)", s, editPart, cleanNameURL(s))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
tagRE := regexp.MustCompile(`#(\S+)`)
|
||||||
|
pageText = tagRE.ReplaceAllStringFunc(pageText, func(s string) string {
|
||||||
|
s = strings.TrimPrefix(s, "#")
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
return fmt.Sprintf(`<a href="/%s" class="tag">%s</a>`, url.PathEscape(cleanNameURL(s)), s)
|
||||||
|
})
|
||||||
|
|
||||||
return pageText
|
return pageText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user