feat(stdlib): Mid M4 csv and thickened text helpers
Add lib/csv parse/stringify and expand lib/text with contains, replace, case, pad, and related golds plus public demos. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
08384c7540
commit
506de65dae
22 files changed
+766
-15
No files matched your search
@@ -1121,6 +1121,32 @@ fn lib_secrets_smoke_zh() {
|
||||
assert_out("tests/lib/机密-烟测.mq.md", "16");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_text_mid_smoke() {
|
||||
assert_out(
|
||||
"tests/lib/text-mid-smoke.mq.md",
|
||||
"True\nAB\na_a_a\n...x\nababab",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_text_mid_smoke_zh() {
|
||||
assert_out("tests/lib/文本-加厚-烟测.mq.md", "True\nAB\na_a-a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_csv_smoke() {
|
||||
assert_out(
|
||||
"tests/lib/csv-smoke.mq.md",
|
||||
"2\nalice\nhi, there\n2",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_csv_smoke_zh() {
|
||||
assert_out("tests/lib/逗号表-烟测.mq.md", "1\n1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_re_smoke() {
|
||||
assert_out(
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: lib/csv smoke
|
||||
import csv:lib/csv.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*raw = "name,note\nalice,\"hi, there\"\nbob,ok\n"*
|
||||
|
||||
*rows = > csv.parse text=`raw`*
|
||||
*n = > len `rows`*
|
||||
> print text=`n`
|
||||
|
||||
*r0 = > at value=`rows` index=0*
|
||||
> print text=`r0`[^name]
|
||||
> print text=`r0`[^note]
|
||||
|
||||
*out = > csv.stringify rows=`rows`*
|
||||
*rows2 = > csv.parse text=`out`*
|
||||
*n2 = > len `rows2`*
|
||||
> print text=`n2`
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: lib/text mid smoke
|
||||
import text:lib/text.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*c = > text.contains text="Hello" sub="ell"*
|
||||
> print text=`c`
|
||||
|
||||
*u = > text.to_upper text="ab"*
|
||||
> print text=`u`
|
||||
|
||||
*r = > text.replace text="a-a-a" old="-" new="_" count=2*
|
||||
> print text=`r`
|
||||
|
||||
*p = > text.pad text="x" width=4 fill="." align="right"*
|
||||
> print text=`p`
|
||||
|
||||
*rep = > text.repeat text="ab" n=3*
|
||||
> print text=`rep`
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: lib/文本 加厚烟测
|
||||
导入 文本:lib/文本.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*c = > 文本.包含 内容="Hello" 子串="ell"*
|
||||
> 打印 内容=`c`
|
||||
|
||||
*u = > 文本.大写 内容="ab"*
|
||||
> 打印 内容=`u`
|
||||
|
||||
*r = > 文本.替换 内容="a-a-a" 旧="-" 新="_" 次数=1*
|
||||
> 打印 内容=`r`
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: lib/逗号表 烟测
|
||||
导入 逗号表:lib/逗号表.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*raw = "a,b\n1,2\n"*
|
||||
|
||||
*rows = > 逗号表.解析 内容=`raw`*
|
||||
*n = > 长度 `rows`*
|
||||
> 打印 内容=`n`
|
||||
|
||||
*r0 = > at value=`rows` index=0*
|
||||
> 打印 内容=`r0`[^a]
|
||||
Reference in new issue
Block a user