migrate: own JSON/CSV and Table serialization; drop the value algorithms
Move JSON, CSV and the Table serialization half of the frozen module to their unique source authority. Value operations now live only in std-collections; there is no second implementation or legacy forwarder. Baseline JSON/CSV and Table GFM expectations are carried into component cases. Refs cflmy/marqdo#9, cflmy/marqdo-std-data#1
This commit was merged in pull request #2.
This commit is contained in:
1 parent
e3c9488dca
commit
848af7a357
13 files changed
+1948
-6
No files matched your search
@@ -0,0 +1,151 @@
|
||||
|
||||
# @exec table
|
||||
## 连接片段
|
||||
|
||||
`params(片段)`
|
||||
|
||||
**结果 = ""**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
`while 下标 < 长度(片段)`
|
||||
|
||||
`if 下标 > 0`
|
||||
|
||||
**结果 = 结果 + " | "**
|
||||
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**忽略 = 0**
|
||||
|
||||
`end`
|
||||
`end`
|
||||
**结果 = 结果 + 片段[下标]**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
`end`
|
||||
`return 结果`
|
||||
|
||||
## 连接行
|
||||
|
||||
`params(行列表)`
|
||||
|
||||
**结果 = ""**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
`while 下标 < 长度(行列表)`
|
||||
|
||||
`if 下标 > 0`
|
||||
|
||||
**结果 = 结果 + "\n"**
|
||||
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**忽略 = 0**
|
||||
|
||||
`end`
|
||||
`end`
|
||||
**结果 = 结果 + 行列表[下标]**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
`end`
|
||||
`return 结果`
|
||||
|
||||
## 转义单元格
|
||||
|
||||
`params(值)`
|
||||
|
||||
**文本值 = 文本(值)**
|
||||
|
||||
**点 = text.codepoints(文本值)**
|
||||
|
||||
**结果 = ""**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
`while 下标 < 长度(点)`
|
||||
|
||||
`if 点[下标] == 124`
|
||||
|
||||
**结果 = 结果 + text.from_codepoint(92) + "|"**
|
||||
|
||||
`else`
|
||||
`if 点[下标] == 10 or 点[下标] == 13`
|
||||
|
||||
**结果 = 结果 + " "**
|
||||
|
||||
`else`
|
||||
`if true`
|
||||
|
||||
**结果 = 结果 + text.from_codepoint(点[下标])**
|
||||
|
||||
`end`
|
||||
`end`
|
||||
`end`
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
`end`
|
||||
`return 结果`
|
||||
|
||||
## 转GFM
|
||||
|
||||
`params(数据)`
|
||||
|
||||
**列名 = table.columns(数据)**
|
||||
|
||||
**表头 = []**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
`while 下标 < 长度(列名)`
|
||||
|
||||
**表头 = list.append(表头, 转义单元格(列名[下标]))**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
`end`
|
||||
**行列表 = []**
|
||||
|
||||
**行列表 = list.append(行列表, "| " + 连接片段(表头) + " |")**
|
||||
|
||||
**分隔 = []**
|
||||
|
||||
**下标 = 0**
|
||||
|
||||
`while 下标 < 长度(列名)`
|
||||
|
||||
**分隔 = list.append(分隔, "---")**
|
||||
|
||||
**下标 = 下标 + 1**
|
||||
|
||||
`end`
|
||||
**行列表 = list.append(行列表, "| " + 连接片段(分隔) + " |")**
|
||||
|
||||
**行号 = 0**
|
||||
|
||||
`while 行号 < 长度(数据)`
|
||||
|
||||
**行 = table.row(数据, 行号)**
|
||||
|
||||
**单元格 = []**
|
||||
|
||||
**列号 = 0**
|
||||
|
||||
`while 列号 < 长度(行)`
|
||||
|
||||
**单元格 = list.append(单元格, 转义单元格(行[列号]))**
|
||||
|
||||
**列号 = 列号 + 1**
|
||||
|
||||
`end`
|
||||
**行列表 = list.append(行列表, "| " + 连接片段(单元格) + " |")**
|
||||
|
||||
**行号 = 行号 + 1**
|
||||
|
||||
`end`
|
||||
`return 连接行(行列表)`
|
||||
Reference in new issue
Block a user