list handling is not working out. Workaround for the time being
This commit is contained in:
parent
0695974353
commit
cc57a49e62
2 changed files with 5 additions and 11 deletions
12
main.go
12
main.go
|
|
@ -35,8 +35,6 @@ var (
|
||||||
inlineCodePattern = regexp.MustCompile("`([^`]+)`")
|
inlineCodePattern = regexp.MustCompile("`([^`]+)`")
|
||||||
codeBlockPattern = regexp.MustCompile("(?s)```(.*?)```")
|
codeBlockPattern = regexp.MustCompile("(?s)```(.*?)```")
|
||||||
blockquotePattern = regexp.MustCompile(`(?m)^> (.+)$`)
|
blockquotePattern = regexp.MustCompile(`(?m)^> (.+)$`)
|
||||||
ulPattern = regexp.MustCompile(`(?m)^(?:- |\*) (.+)$`)
|
|
||||||
olPattern = regexp.MustCompile(`(?m)^\d+\. (.+)$`)
|
|
||||||
linkPattern = regexp.MustCompile(`\[(.*?)\]\((.*?)\)`)
|
linkPattern = regexp.MustCompile(`\[(.*?)\]\((.*?)\)`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -104,17 +102,9 @@ func renderMarkdown(content string) template.HTML {
|
||||||
content = blockquotePattern.ReplaceAllString(content, "<blockquote>$1</blockquote>")
|
content = blockquotePattern.ReplaceAllString(content, "<blockquote>$1</blockquote>")
|
||||||
content = linkPattern.ReplaceAllString(content, `<a href="$2">$1</a>`)
|
content = linkPattern.ReplaceAllString(content, `<a href="$2">$1</a>`)
|
||||||
|
|
||||||
// Handle lists properly
|
|
||||||
//content = ulPattern.ReplaceAllString(content, "<li>$1</li>")
|
|
||||||
//content = olPattern.ReplaceAllString(content, "<li>$1</li>")
|
|
||||||
//content = regexp.MustCompile(`(?m)(<li>.+?</li>)`).ReplaceAllString(content, "<ul>$1</ul>")
|
|
||||||
//content = regexp.MustCompile(`(?m)(<ul>(?:<li>.+?</li>)+)</ul>`).ReplaceAllString(content, "$1")
|
|
||||||
//content = regexp.MustCompile(`(?m)(<li>.+?</li>)`).ReplaceAllString(content, "<ol>$1</ol>")
|
|
||||||
//content = regexp.MustCompile(`(?m)(<ol>(?:<li>.+?</li>)+)</ol>`).ReplaceAllString(content, "$1")
|
|
||||||
|
|
||||||
// Preserve paragraph structure without breaking inline elements
|
// Preserve paragraph structure without breaking inline elements
|
||||||
paragraphPattern := regexp.MustCompile(`(?m)(^([^#<\n].+)$)\n?`)
|
paragraphPattern := regexp.MustCompile(`(?m)(^([^#<\n].+)$)\n?`)
|
||||||
content = paragraphPattern.ReplaceAllString(content, "<p>$1</p>")
|
content = paragraphPattern.ReplaceAllString(content, "<p><pre>$1</pre></p>")
|
||||||
|
|
||||||
return template.HTML(content)
|
return template.HTML(content)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@
|
||||||
margin: 25px;
|
margin: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue