文章排版四件套(参考 xLog):盘古之白 + 表格圆角斑马纹 + 代码块封顶与复制按钮 + 标题悬停锚点

- PanguHTML:CJK 与拉丁/数字间补空格,标签原样保留、code/pre 内文本不动;详情/时间线短文/RSS 描述三个出口生效(带单测)
- 表格改圆角容器 + tbody 斑马纹 + 纵向大留白(classic/vivid 双主题)
- pre max-height 30.5em 封顶内部滚动;enhanceProse 注入悬停复制按钮(App 全局委托),按下有 2px 物理感
- 带 id 的 h2-h4 悬停浮现 # 锚点,点击跳转
- 中文字体栈此前已配(PingFang SC 等),无需改动
This commit is contained in:
Sakurasan
2026-09-29 00:53:50 +08:00
parent 44a24736aa
commit 23771f0661
7 changed files with 257 additions and 14 deletions
+10 -1
View File
@@ -18,6 +18,7 @@ import (
"oneblog/internal/hub"
"oneblog/internal/model"
"oneblog/internal/ratelimit"
"oneblog/internal/render"
"oneblog/internal/storage"
"oneblog/internal/store"
"oneblog/internal/thumbs"
@@ -128,6 +129,12 @@ func (a *API) listPosts(w http.ResponseWriter, r *http.Request) {
httpx.ServerError(w, err)
return
}
// 时间线上短文直接铺正文:出口处做盘古之白(库里存的是原始渲染结果)
for i := range page.Items {
if page.Items[i].Kind == model.KindShort {
page.Items[i].ContentHTML = render.PanguHTML(page.Items[i].ContentHTML)
}
}
httpx.OK(w, page)
}
@@ -156,6 +163,8 @@ func (a *API) getPost(w http.ResponseWriter, r *http.Request) {
if err != nil {
nb = nil
}
// 详情正文出口做盘古之白(存库不动,改的是渲染层)
p.ContentHTML = render.PanguHTML(p.ContentHTML)
httpx.OK(w, struct {
model.Post
Neighbors []model.Post `json:"neighbors"`
@@ -255,7 +264,7 @@ func (a *API) RSS(w http.ResponseWriter, r *http.Request) {
}
desc := p.Summary
if desc == "" {
desc = trimRunes(stripTags(p.ContentHTML), 160)
desc = trimRunes(stripTags(render.PanguHTML(p.ContentHTML)), 160)
}
item := rssItem{
Title: title,