From cc57a49e62f5530e10da4cccb6daf297bbb2b63a Mon Sep 17 00:00:00 2001 From: zhanshi Date: Tue, 4 Mar 2025 20:46:24 +0100 Subject: [PATCH] list handling is not working out. Workaround for the time being --- main.go | 12 +----------- templates/post.html | 4 ++++ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index ccfd9a7..8322c19 100644 --- a/main.go +++ b/main.go @@ -35,8 +35,6 @@ var ( inlineCodePattern = regexp.MustCompile("`([^`]+)`") codeBlockPattern = regexp.MustCompile("(?s)```(.*?)```") blockquotePattern = regexp.MustCompile(`(?m)^> (.+)$`) - ulPattern = regexp.MustCompile(`(?m)^(?:- |\*) (.+)$`) - olPattern = regexp.MustCompile(`(?m)^\d+\. (.+)$`) linkPattern = regexp.MustCompile(`\[(.*?)\]\((.*?)\)`) ) @@ -104,17 +102,9 @@ func renderMarkdown(content string) template.HTML { content = blockquotePattern.ReplaceAllString(content, "
$1
") content = linkPattern.ReplaceAllString(content, `$1`) - // Handle lists properly - //content = ulPattern.ReplaceAllString(content, "
  • $1
  • ") - //content = olPattern.ReplaceAllString(content, "
  • $1
  • ") - //content = regexp.MustCompile(`(?m)(
  • .+?
  • )`).ReplaceAllString(content, "") - //content = regexp.MustCompile(`(?m)(`).ReplaceAllString(content, "$1") - //content = regexp.MustCompile(`(?m)(
  • .+?
  • )`).ReplaceAllString(content, "
      $1
    ") - //content = regexp.MustCompile(`(?m)(
      (?:
    1. .+?
    2. )+)
    `).ReplaceAllString(content, "$1") - // Preserve paragraph structure without breaking inline elements paragraphPattern := regexp.MustCompile(`(?m)(^([^#<\n].+)$)\n?`) - content = paragraphPattern.ReplaceAllString(content, "

    $1

    ") + content = paragraphPattern.ReplaceAllString(content, "

    $1

    ") return template.HTML(content) } diff --git a/templates/post.html b/templates/post.html index 38d0d8d..6657c80 100644 --- a/templates/post.html +++ b/templates/post.html @@ -9,6 +9,10 @@ margin: 25px; } + pre { + font-family: inherit; + } + img { vertical-align: middle; }