Files
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

64 lines
1.2 KiB
Go
Executable File

// Package style implements web_style (CSS from GFM style tables).
package style
import (
"strconv"
"strings"
"github.com/marqdo/marqdo/plugins/web/internal/table"
)
// Style matches Rust web_style: args name + table + optional strict → CSS string.
func Style(args map[string]any) (string, error) {
name := ""
if v, ok := args["name"]; ok && v != nil {
name = cellStr(v)
}
var tbl any = []any{}
if v, ok := args["table"]; ok && v != nil {
tbl = v
}
strict := false
for _, k := range []string{"strict", "strict_css_cells", "严格"} {
if v, ok := args[k]; ok {
strict = boolishStrict(v)
break
}
}
return table.AsCSSNamedChecked(name, tbl, strict)
}
func cellStr(v any) string {
switch t := v.(type) {
case string:
return t
case float64:
if t == float64(int64(t)) {
return strconv.FormatInt(int64(t), 10)
}
return strconv.FormatFloat(t, 'f', -1, 64)
case bool:
return strconv.FormatBool(t)
default:
return ""
}
}
func boolishStrict(v any) bool {
switch t := v.(type) {
case bool:
return t
case float64:
return int64(t) != 0
case string:
s := strings.TrimSpace(t)
switch s {
case "1", "true", "True", "yes", "on", "真", "是":
return true
}
return false
default:
return false
}
}