ttrpg-tools/README.md

86 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TTRPG Tools
一个基于 `solid.js``rsbuild``ttrpg` 工具箱。
## 功能
- **CLI**: 提供一个 cli 工具,用于将目录内的各种 ttrpg 文档编译为 html。
- **Markdown**: 解析以各种格式编写的 ttrpg 内容,并支持扩展的语法。
- **TTRPG 组件**: 用于 ttrpg 内容的各种 UI 组件,且可以在 markdown 中通过扩展语法插入。
## CLI 命令
```bash
# 克隆仓库后npm install & npm link安装
# 在项目文件夹内运行
ttrpg serve [dir] -p 3000
```
## 组件语法
### 骰子组件
```markdown
:dice[2d6+d8]
:dice[1d20+5]{key="attack"}
```
### 表格组件
```markdown
:table[./sparks.csv]
:table[./sparks.csv]{roll=true}
:table[./sparks.csv]{roll=true remix=true}
```
### 卡牌组件
假设准备有`./cards.csv`内容如下:
```csv
label,title,body
1,卡牌1,这张卡牌的**效果**的markdown文本
2,卡牌2,更多卡牌效果
```
```markdown
:md-deck[./cards.csv]{grid="5x8" layers="title:1,1-5,1f8 body:1,5-5,8f3"}
```
上述卡牌将生成5x8的卡牌牌面排版其中title层占第1行1-5列8mm字体。
## 开发
```bash
# 安装依赖
npm install
# 开发模式
npm run dev
# 构建
npm run build
# 预览
npm run preview
```
## 项目结构
```
ttrpg-tools/
├── src/
│ ├── cli/ # CLI 工具源码
│ ├── components/ # TTRPG 组件
│ ├── markdown/ # Markdown 解析器
│ ├── App.tsx # 主应用组件
│ ├── main.tsx # 入口文件
│ └── styles.css # 样式文件
├── content/ # 示例内容
├── package.json
├── tsconfig.json
└── rsbuild.config.ts
```