This commit is contained in:
Daniel 2024-12-12 16:41:30 +08:00
parent 2f39c2f1bc
commit 29b5124591
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 176 additions and 22 deletions

View file

@ -6,7 +6,7 @@
"id": "20201204184532-3qm9l8n", "id": "20201204184532-3qm9l8n",
"title": "Template snippet", "title": "Template snippet",
"type": "doc", "type": "doc",
"updated": "20241212102051" "updated": "20241212163918"
}, },
"Children": [ "Children": [
{ {
@ -57,7 +57,7 @@
"HeadingLevel": 2, "HeadingLevel": 2,
"Properties": { "Properties": {
"id": "20210104091444-jy56z0p", "id": "20210104091444-jy56z0p",
"updated": "20241212102051" "updated": "20241212163918"
}, },
"Children": [ "Children": [
{ {
@ -215,7 +215,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20210104091444-mwbvc9m", "id": "20210104091444-mwbvc9m",
"updated": "20241212102051" "updated": "20241212163918"
}, },
"Children": [ "Children": [
{ {
@ -495,7 +495,7 @@
}, },
"Properties": { "Properties": {
"id": "20241212102027-j293sei", "id": "20241212102027-j293sei",
"updated": "20241212102051" "updated": "20241212163902"
}, },
"Children": [ "Children": [
{ {
@ -503,7 +503,7 @@
"Type": "NodeParagraph", "Type": "NodeParagraph",
"Properties": { "Properties": {
"id": "20241212102028-6c8tlnu", "id": "20241212102028-6c8tlnu",
"updated": "20241212102051" "updated": "20241212163902"
}, },
"Children": [ "Children": [
{ {
@ -517,7 +517,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": ": Statistics block content" "Data": ": This function is used to count the block content"
} }
] ]
}, },
@ -750,6 +750,43 @@
} }
] ]
}, },
{
"ID": "20241212163841-3yjhffn",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20241212163841-3yjhffn",
"updated": "20241212163918"
},
"Children": [
{
"ID": "20241212163841-d8t3qxb",
"Type": "NodeParagraph",
"Properties": {
"id": "20241212163841-d8t3qxb",
"updated": "20241212163918"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "runeLen"
},
{
"Type": "NodeText",
"Data": ": This function is used to return the string length"
}
]
}
]
},
{ {
"ID": "20211213121042-5n981ru", "ID": "20211213121042-5n981ru",
"Type": "NodeListItem", "Type": "NodeListItem",

View file

@ -6,7 +6,7 @@
"id": "20201204181006-7bkppue", "id": "20201204181006-7bkppue",
"title": "模板片段", "title": "模板片段",
"type": "doc", "type": "doc",
"updated": "20241212101821" "updated": "20241212163739"
}, },
"Children": [ "Children": [
{ {
@ -69,7 +69,7 @@
"HeadingLevel": 2, "HeadingLevel": 2,
"Properties": { "Properties": {
"id": "20210104091309-fhb549c", "id": "20210104091309-fhb549c",
"updated": "20241212101821" "updated": "20241212163739"
}, },
"Children": [ "Children": [
{ {
@ -237,7 +237,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20210104091309-gjkg3u5", "id": "20210104091309-gjkg3u5",
"updated": "20241212101821" "updated": "20241212163739"
}, },
"Children": [ "Children": [
{ {
@ -517,7 +517,7 @@
}, },
"Properties": { "Properties": {
"id": "20241212101708-0euo6is", "id": "20241212101708-0euo6is",
"updated": "20241212101821" "updated": "20241212163723"
}, },
"Children": [ "Children": [
{ {
@ -525,7 +525,7 @@
"Type": "NodeParagraph", "Type": "NodeParagraph",
"Properties": { "Properties": {
"id": "20241212101708-llv0ngj", "id": "20241212101708-llv0ngj",
"updated": "20241212101734" "updated": "20241212163723"
}, },
"Children": [ "Children": [
{ {
@ -539,7 +539,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:统计块内容" "Data": "该函数用于统计块内容"
} }
] ]
}, },
@ -772,6 +772,43 @@
} }
] ]
}, },
{
"ID": "20241212163704-qmyz1ss",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20241212163704-qmyz1ss",
"updated": "20241212163739"
},
"Children": [
{
"ID": "20241212163704-i9p11h6",
"Type": "NodeParagraph",
"Properties": {
"id": "20241212163704-i9p11h6",
"updated": "20241212163739"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "runeLen"
},
{
"Type": "NodeText",
"Data": "​:该函数用于返回字符串长度"
}
]
}
]
},
{ {
"ID": "20211213120813-ppm3j85", "ID": "20211213120813-ppm3j85",
"Type": "NodeListItem", "Type": "NodeListItem",

View file

@ -6,7 +6,7 @@
"id": "20211226123004-dplpw0o", "id": "20211226123004-dplpw0o",
"title": "範本片段", "title": "範本片段",
"type": "doc", "type": "doc",
"updated": "20241212102113" "updated": "20241212164017"
}, },
"Children": [ "Children": [
{ {
@ -53,7 +53,7 @@
"HeadingLevel": 2, "HeadingLevel": 2,
"Properties": { "Properties": {
"id": "20211226123024-eyagqur", "id": "20211226123024-eyagqur",
"updated": "20241212102113" "updated": "20241212164017"
}, },
"Children": [ "Children": [
{ {
@ -208,7 +208,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20211226123024-pjvw31z", "id": "20211226123024-pjvw31z",
"updated": "20241212102113" "updated": "20241212164017"
}, },
"Children": [ "Children": [
{ {
@ -496,7 +496,7 @@
"Type": "NodeParagraph", "Type": "NodeParagraph",
"Properties": { "Properties": {
"id": "20241212102021-54wv84h", "id": "20241212102021-54wv84h",
"updated": "20241212102113" "updated": "20241212164010"
}, },
"Children": [ "Children": [
{ {
@ -510,7 +510,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "​:統計區塊內容" "Data": "此函數用於統計區塊內容"
} }
] ]
}, },
@ -743,6 +743,43 @@
} }
] ]
}, },
{
"ID": "20241212164016-nxteno5",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20241212164016-nxteno5",
"updated": "20241212164017"
},
"Children": [
{
"ID": "20241212164016-ot8vo9l",
"Type": "NodeParagraph",
"Properties": {
"id": "20241212164016-ot8vo9l",
"updated": "20241212164017"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "runeLen"
},
{
"Type": "NodeText",
"Data": "​:此函數用於傳回字串長度"
}
]
}
]
},
{ {
"ID": "20211226123024-kca62r8", "ID": "20211226123024-kca62r8",
"Type": "NodeListItem", "Type": "NodeListItem",

View file

@ -7,7 +7,7 @@
"id": "20240530101000-6x9ivi7", "id": "20240530101000-6x9ivi7",
"title": "テンプレートスニペット", "title": "テンプレートスニペット",
"type": "doc", "type": "doc",
"updated": "20241212102145" "updated": "20241212163955"
}, },
"Children": [ "Children": [
{ {
@ -66,7 +66,7 @@
"Properties": { "Properties": {
"ID": "20240530101000-5nvn9ad", "ID": "20240530101000-5nvn9ad",
"id": "20240530101000-pi05yzt", "id": "20240530101000-pi05yzt",
"updated": "20241212102145" "updated": "20241212163955"
}, },
"Children": [ "Children": [
{ {
@ -226,7 +226,7 @@
"ListData": {}, "ListData": {},
"Properties": { "Properties": {
"id": "20240530101000-by5hqnb", "id": "20240530101000-by5hqnb",
"updated": "20241212102145" "updated": "20241212163955"
}, },
"Children": [ "Children": [
{ {
@ -514,7 +514,7 @@
"Type": "NodeParagraph", "Type": "NodeParagraph",
"Properties": { "Properties": {
"id": "20241212102033-d4azb7k", "id": "20241212102033-d4azb7k",
"updated": "20241212102145" "updated": "20241212163936"
}, },
"Children": [ "Children": [
{ {
@ -528,7 +528,7 @@
}, },
{ {
"Type": "NodeText", "Type": "NodeText",
"Data": "統計ブロックの内容" "Data": "この関数はブロックの内容を数えるために使用されます"
} }
] ]
}, },
@ -761,6 +761,43 @@
} }
] ]
}, },
{
"ID": "20241212163938-ewajrsj",
"Type": "NodeListItem",
"ListData": {
"BulletChar": 42,
"Marker": "Kg=="
},
"Properties": {
"id": "20241212163938-ewajrsj",
"updated": "20241212163955"
},
"Children": [
{
"ID": "20241212163938-y1al3b9",
"Type": "NodeParagraph",
"Properties": {
"id": "20241212163938-y1al3b9",
"updated": "20241212163955"
},
"Children": [
{
"Type": "NodeText",
"Data": ""
},
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "runeLen"
},
{
"Type": "NodeText",
"Data": ": この関数は文字列の長さを返すために使用されます"
}
]
}
]
},
{ {
"ID": "20240530101000-xhrxvp5", "ID": "20240530101000-xhrxvp5",
"Type": "NodeListItem", "Type": "NodeListItem",

View file

@ -20,6 +20,7 @@ import (
"math" "math"
"text/template" "text/template"
"time" "time"
"unicode/utf8"
"github.com/88250/go-humanize" "github.com/88250/go-humanize"
"github.com/Masterminds/sprig/v3" "github.com/Masterminds/sprig/v3"
@ -50,9 +51,14 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) {
ret["FormatFloat"] = FormatFloat ret["FormatFloat"] = FormatFloat
ret["getHPathByID"] = getHPathByID ret["getHPathByID"] = getHPathByID
ret["statBlock"] = StatBlock ret["statBlock"] = StatBlock
ret["runeLen"] = runeLen
return return
} }
func runeLen(s string) int {
return utf8.RuneCountInString(s)
}
func pow(a, b interface{}) int64 { return int64(math.Pow(cast.ToFloat64(a), cast.ToFloat64(b))) } func pow(a, b interface{}) int64 { return int64(math.Pow(cast.ToFloat64(a), cast.ToFloat64(b))) }
func powf(a, b interface{}) float64 { return math.Pow(cast.ToFloat64(a), cast.ToFloat64(b)) } func powf(a, b interface{}) float64 { return math.Pow(cast.ToFloat64(a), cast.ToFloat64(b)) }
func log(a, b interface{}) int64 { func log(a, b interface{}) int64 {