mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-22 13:47:42 +00:00
support multiple spoiler tags
This commit is contained in:
parent
4991a2e5ed
commit
8e270007f4
|
@ -10,6 +10,9 @@ body.dark {
|
||||||
code {
|
code {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
summary {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
.dark a {
|
.dark a {
|
||||||
color: #8cb3d9;
|
color: #8cb3d9;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,8 @@ var funcMap = template.FuncMap{
|
||||||
"humanize": humanize.Time,
|
"humanize": humanize.Time,
|
||||||
"markdown": func(host string, body string) template.HTML {
|
"markdown": func(host string, body string) template.HTML {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
re := regexp.MustCompile(`\s---\s`)
|
||||||
|
body = re.ReplaceAllString(body, "\n***\n")
|
||||||
if err := md.Convert([]byte(body), &buf); err != nil {
|
if err := md.Convert([]byte(body), &buf); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return template.HTML(body)
|
return template.HTML(body)
|
||||||
|
@ -124,11 +126,11 @@ var funcMap = template.FuncMap{
|
||||||
re := regexp.MustCompile(`href="https:\/\/([a-zA-Z0-9\.\-]+\/(c\/[a-zA-Z0-9]+|(post|comment)\/\d+))`)
|
re := regexp.MustCompile(`href="https:\/\/([a-zA-Z0-9\.\-]+\/(c\/[a-zA-Z0-9]+|(post|comment)\/\d+))`)
|
||||||
converted = re.ReplaceAllString(converted, `href="/$1`)
|
converted = re.ReplaceAllString(converted, `href="/$1`)
|
||||||
}
|
}
|
||||||
re := regexp.MustCompile(`href="\/(c\/[a-zA-Z0-9\-]+|(post|comment)\/\d+)`)
|
re = regexp.MustCompile(`href="\/(c\/[a-zA-Z0-9\-]+|(post|comment)\/\d+)`)
|
||||||
converted = re.ReplaceAllString(converted, `href="/`+host+`/$1`)
|
converted = re.ReplaceAllString(converted, `href="/`+host+`/$1`)
|
||||||
re = regexp.MustCompile(` !([a-zA-Z0-9]+)@([a-zA-Z0-9\.\-]+) `)
|
re = regexp.MustCompile(` !([a-zA-Z0-9]+)@([a-zA-Z0-9\.\-]+) `)
|
||||||
converted = re.ReplaceAllString(converted, ` <a href="/$2/c/$1">!$1@$2</a> `)
|
converted = re.ReplaceAllString(converted, ` <a href="/$2/c/$1">!$1@$2</a> `)
|
||||||
re = regexp.MustCompile(`::: spoiler ([^\n]*)\n([\S\s\n]*):::`)
|
re = regexp.MustCompile(`::: spoiler (.*?)\n(.*?)\s:::`)
|
||||||
converted = re.ReplaceAllString(converted, "<details><summary>$1</summary>$2</details>")
|
converted = re.ReplaceAllString(converted, "<details><summary>$1</summary>$2</details>")
|
||||||
return template.HTML(converted)
|
return template.HTML(converted)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue