release: v1.0.1 — fix Go libweb dynamic-route query, Markdown, CSS false positives
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
761b92afce
commit
3eb8e732ea
17 files changed
+375
-43
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package render
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"github.com/yuin/goldmark/parser"
|
||||
"github.com/yuin/goldmark/renderer/html"
|
||||
)
|
||||
|
||||
// markdownToHTML renders article body Markdown to HTML (GFM subset), matching
|
||||
// the Rust web plugin's pulldown-cmark path.
|
||||
func markdownToHTML(md string) string {
|
||||
md = strings.TrimSpace(md)
|
||||
if md == "" {
|
||||
return ""
|
||||
}
|
||||
gm := goldmark.New(
|
||||
goldmark.WithExtensions(
|
||||
extension.GFM,
|
||||
extension.Strikethrough,
|
||||
),
|
||||
goldmark.WithParserOptions(
|
||||
parser.WithAutoHeadingID(),
|
||||
),
|
||||
goldmark.WithRendererOptions(
|
||||
html.WithHardWraps(),
|
||||
html.WithXHTML(),
|
||||
),
|
||||
)
|
||||
var buf bytes.Buffer
|
||||
if err := gm.Convert([]byte(md), &buf); err != nil {
|
||||
return `<div class="article-body"><p class="article-p">` + esc(md) + `</p></div>`
|
||||
}
|
||||
return `<div class="article-body md">` + buf.String() + `</div>`
|
||||
}
|
||||
Reference in new issue
Block a user