diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy index 76f09f43c..a94b5d623 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201204184532-3qm9l8n.sy @@ -6,7 +6,7 @@ "id": "20201204184532-3qm9l8n", "title": "Template snippet", "type": "doc", - "updated": "20241212102051" + "updated": "20241212163918" }, "Children": [ { @@ -57,7 +57,7 @@ "HeadingLevel": 2, "Properties": { "id": "20210104091444-jy56z0p", - "updated": "20241212102051" + "updated": "20241212163918" }, "Children": [ { @@ -215,7 +215,7 @@ "ListData": {}, "Properties": { "id": "20210104091444-mwbvc9m", - "updated": "20241212102051" + "updated": "20241212163918" }, "Children": [ { @@ -495,7 +495,7 @@ }, "Properties": { "id": "20241212102027-j293sei", - "updated": "20241212102051" + "updated": "20241212163902" }, "Children": [ { @@ -503,7 +503,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20241212102028-6c8tlnu", - "updated": "20241212102051" + "updated": "20241212163902" }, "Children": [ { @@ -517,7 +517,7 @@ }, { "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", "Type": "NodeListItem", diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy index bd9828e66..a5ea9dbea 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201204181006-7bkppue.sy @@ -6,7 +6,7 @@ "id": "20201204181006-7bkppue", "title": "模板片段", "type": "doc", - "updated": "20241212101821" + "updated": "20241212163739" }, "Children": [ { @@ -69,7 +69,7 @@ "HeadingLevel": 2, "Properties": { "id": "20210104091309-fhb549c", - "updated": "20241212101821" + "updated": "20241212163739" }, "Children": [ { @@ -237,7 +237,7 @@ "ListData": {}, "Properties": { "id": "20210104091309-gjkg3u5", - "updated": "20241212101821" + "updated": "20241212163739" }, "Children": [ { @@ -517,7 +517,7 @@ }, "Properties": { "id": "20241212101708-0euo6is", - "updated": "20241212101821" + "updated": "20241212163723" }, "Children": [ { @@ -525,7 +525,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20241212101708-llv0ngj", - "updated": "20241212101734" + "updated": "20241212163723" }, "Children": [ { @@ -539,7 +539,7 @@ }, { "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", "Type": "NodeListItem", diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy index 6625d463f..7b72c685f 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226123004-dplpw0o.sy @@ -6,7 +6,7 @@ "id": "20211226123004-dplpw0o", "title": "範本片段", "type": "doc", - "updated": "20241212102113" + "updated": "20241212164017" }, "Children": [ { @@ -53,7 +53,7 @@ "HeadingLevel": 2, "Properties": { "id": "20211226123024-eyagqur", - "updated": "20241212102113" + "updated": "20241212164017" }, "Children": [ { @@ -208,7 +208,7 @@ "ListData": {}, "Properties": { "id": "20211226123024-pjvw31z", - "updated": "20241212102113" + "updated": "20241212164017" }, "Children": [ { @@ -496,7 +496,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20241212102021-54wv84h", - "updated": "20241212102113" + "updated": "20241212164010" }, "Children": [ { @@ -510,7 +510,7 @@ }, { "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", "Type": "NodeListItem", diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy index 51d79a7ea..25ebb055d 100644 --- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy +++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-6x9ivi7.sy @@ -7,7 +7,7 @@ "id": "20240530101000-6x9ivi7", "title": "テンプレートスニペット", "type": "doc", - "updated": "20241212102145" + "updated": "20241212163955" }, "Children": [ { @@ -66,7 +66,7 @@ "Properties": { "ID": "20240530101000-5nvn9ad", "id": "20240530101000-pi05yzt", - "updated": "20241212102145" + "updated": "20241212163955" }, "Children": [ { @@ -226,7 +226,7 @@ "ListData": {}, "Properties": { "id": "20240530101000-by5hqnb", - "updated": "20241212102145" + "updated": "20241212163955" }, "Children": [ { @@ -514,7 +514,7 @@ "Type": "NodeParagraph", "Properties": { "id": "20241212102033-d4azb7k", - "updated": "20241212102145" + "updated": "20241212163936" }, "Children": [ { @@ -528,7 +528,7 @@ }, { "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", "Type": "NodeListItem", diff --git a/kernel/filesys/template.go b/kernel/filesys/template.go index 38654f39f..5a69a4f2d 100644 --- a/kernel/filesys/template.go +++ b/kernel/filesys/template.go @@ -20,6 +20,7 @@ import ( "math" "text/template" "time" + "unicode/utf8" "github.com/88250/go-humanize" "github.com/Masterminds/sprig/v3" @@ -50,9 +51,14 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) { ret["FormatFloat"] = FormatFloat ret["getHPathByID"] = getHPathByID ret["statBlock"] = StatBlock + ret["runeLen"] = runeLen 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 powf(a, b interface{}) float64 { return math.Pow(cast.ToFloat64(a), cast.ToFloat64(b)) } func log(a, b interface{}) int64 {