# 脚本渲染规则 脚本渲染规则只影响 TypeScript 文件在编辑器和导出中的展示格式,不改变 `SetText` 的编码语义和 PVF 内的 token 数据。 ## 配置位置 开发环境使用仓库根目录的 `config/rendering.json`。应用启动时使用内置的 默认配置;设置中的“渲染规则热重载”会重新读取开发环境配置,发布环境则 读取用户配置目录下的 `pvfine/rendering.json`。 ## JSON 结构 ```json { "version": 1, "description": "script rendering rules", "rules": [ { "id": "skl.custom-section", "match": { "extensions": [".skl"], "glob": "skills/**/*.skl" }, "target": { "kind": "section", "section": "custom section" }, "format": { "offset": 2, "tokensPerLineIndex": 0, "tokensPerLine": 4 } } ] } ``` `target.kind` 为 `file` 时规则作用于整个文件;为 `section` 时按 section 名称匹配,同名 section 全部应用规则。后缀、路径和 section 名称均不区分 大小写。`tokensPerLine` 必须为正数。`offset` 表示前多少个 token 各自 单独占一行;`tokensPerLineIndex` 为 section 内从 0 开始的 token 下标, 对应 token 的正整数值会覆盖 `tokensPerLine`,通常与 `offset` 配合使用。 动态值缺失或无效时回退到配置中的 `tokensPerLine`。 同一作用域下,后缀或 glob 约束更多的规则优先;约束相同时使用 JSON 中 靠后的规则。section 规则始终覆盖 file 规则,file 规则作为没有专用 section 规则时的回退。