♻️ refactor(handlers): status 与 review 页面模板化
- HTML 提取至 templates/status.html、templates/review.html(go:embed 内嵌) - status.go 1022→271 行、review.go 1281→438 行,动态数据全部经 html/template 按上下文自动转义 - 评论循环/作者徽章/贴纸/图片条件渲染翻译为模板 range/if;emojiMap 以 template.JS 注入 - 与旧版渲染输出实测对比:22 条评论结构完全一致;差异仅为 JS 上下文安全转义(& 等)与 html/template 剥除 CSS 注释,均无功能影响 - 其余文件为 gofmt 顺手格式化
This commit is contained in:
1 parent
ad6d28fd85
commit
5bcc8a962e
29 files changed
+1267
-2893
No files matched your search
@@ -13,7 +13,6 @@ var (
|
||||
parserLogger = common.NewLogger("content_parser", "INFO", "")
|
||||
)
|
||||
|
||||
|
||||
// ContentParser 内容解析器
|
||||
type ContentParser struct {
|
||||
cfg config.ContentConfig
|
||||
@@ -143,13 +142,13 @@ func (p *ContentParser) extractText(content string) string {
|
||||
|
||||
// 拼接结果
|
||||
var result string
|
||||
|
||||
|
||||
// 根据配置决定段落间的换行符
|
||||
separator := "\n"
|
||||
if p.cfg.DoubleNewline {
|
||||
separator = "\n\n"
|
||||
}
|
||||
|
||||
|
||||
if p.cfg.AddParagraphIndent && len(finalResult) > 0 {
|
||||
// 添加段落缩进(两个全角空格)
|
||||
result = "\u3000\u3000" + strings.Join(finalResult, separator+"\u3000\u3000")
|
||||
@@ -170,10 +169,10 @@ func (p *ContentParser) extractText(content string) string {
|
||||
func (p *ContentParser) processHTMLMode(content string) string {
|
||||
// 标准化img属性
|
||||
content = normalizeImgAttributes(content)
|
||||
|
||||
|
||||
// 解码HTML实体
|
||||
content = decodeHTMLEntities(content)
|
||||
|
||||
|
||||
// 根据配置决定是否移除空行
|
||||
if p.cfg.RemoveBlankLines {
|
||||
// 对HTML内容移除空的<p>标签
|
||||
@@ -184,4 +183,3 @@ func (p *ContentParser) processHTMLMode(content string) string {
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user