feat(md-deck): support structured data-config with template layers
Allow md-deck layers to render markdown templates via {{var}}
substitution instead of only CSV props. Add config.ts to normalize
a JSON data-config attribute (size, grid, shape, layers) emitted by
the yaml code-block tag, taking precedence over legacy string props.
This commit is contained in:
@@ -6,7 +6,7 @@ title: 卡牌组件
|
||||
|
||||
将 CSV 数据渲染为可打印的卡牌布局,支持自定义尺寸、网格、图层和双面排版。
|
||||
|
||||
**语法:** `:md-deck[./cards.csv]{选项}`
|
||||
**语法:** `:md-deck[./cards.csv]{选项}` 或 ```yaml/tag 代码块
|
||||
|
||||
**基础卡牌:**
|
||||
:md-deck[./spells.csv]{grid="3x3"}
|
||||
@@ -16,6 +16,36 @@ title: 卡牌组件
|
||||
|
||||
CSV 包含数据字段列,通过图层定义控制各字段的位置、大小和对齐。
|
||||
|
||||
## 结构化配置 (yaml/tag)
|
||||
|
||||
```yaml/tag 代码块可以用 `body` 指定 CSV 路径,`data-config` 提供结构化配置,图层可以是字段(`prop`)或 markdown 模板(`template`,支持 `{{变量}}` 替换):
|
||||
|
||||
````markdown
|
||||
```yaml/tag
|
||||
tag: md-deck
|
||||
body: ./cards.csv
|
||||
data-config:
|
||||
size: 63x88
|
||||
grid: 5x5
|
||||
layers:
|
||||
- prop: title
|
||||
x1: 1
|
||||
y1: 1
|
||||
x2: 5
|
||||
y2: 1
|
||||
font: 12
|
||||
- template: |
|
||||
**{{name}}** — {{type}}
|
||||
{{description}}
|
||||
x1: 1
|
||||
y1: 3
|
||||
x2: 5
|
||||
y2: 8
|
||||
font: 3
|
||||
align: l
|
||||
```
|
||||
````
|
||||
|
||||
## 图层格式
|
||||
|
||||
`layers` 属性格式为 `字段:起始行,起始列-结束列,字号`,多个图层用空格分隔:
|
||||
|
||||
Reference in New Issue
Block a user