角色介绍

角色介绍

【免费下载链接】novelWriter novelWriter is an open source plain text editor designed for writing novels. It supports a minimal markdown-like syntax for formatting text. It is written with Python 3 (3.8+) and Qt 5 (5.10+) for cross-platform support. 【免费下载链接】novelWriter 项目地址: https://gitcode.com/gh_mirrors/no/novelWriter

@tag:protagonist|主角 @tag:antagonist|反派

@char:protagonist: 亚瑟·潘德拉贡

  • 身份:卡梅洛特君主
  • 性格:勇敢但多疑

@char:antagonist: 莫甘娜

  • 身份:亚瑟的对手
  • 性格:狡猾且野心勃勃

**关键语法规则**:
- 标签键(key)必须唯一,建议使用小写字母+下划线命名法
- 显示名称(display name)支持空格与特殊字符,仅影响显示
- 标签定义必须在独立行,不能嵌入段落文本中

**标签引用**使用`@keyword:tagkey`语法,系统支持多种预定义关键词:

| 关键词 | 用途 | 示例 |
|--------|------|------|
| `@char` | 角色引用 | `@char:protagonist` |
| `@scene` | 场景引用 | `@scene:castle_battle` |
| `@item` | 物品引用 | `@item:excalibur` |
| `@note` | 笔记引用 | `@note:magic_system` |
| `@ref` | 通用引用 | `@ref:prophecy_3` |

> **最佳实践**:创建标签时始终指定显示名称,如`@tag:mc|Main Character`,可显著提升文档可读性。引用时使用关键词前缀,帮助系统理解引用类型,获得更精准的自动补全建议。

### 中级应用:多文档关联与管理

当项目包含多个文档时,标签系统可实现**跨文档内容组织**。通过`Index`类的`getBackReferenceList`方法,系统能追踪标签的所有引用位置:

```python
def getBackReferenceList(self, tHandle: str) -> dict[str, tuple[str, IndexHeading]]:
    """Build a dict of files referring back to a tag"""
    if tHandle not in self._itemIndex:
        return {}

    tRefs = {}
    tTags = self._itemIndex.allItemTags(tHandle)
    for aHandle, sTitle, hItem in self._itemIndex.iterAllHeaders():
        for aTag in hItem.references:
            if aTag in tTags and aHandle not in tRefs:
                tRefs[aHandle] = (sTitle, hItem)
    return tRefs

实操场景

  1. 角色出场统计:通过引用列表追踪角色在各章节的出场次数
  2. 情节线索管理:使用@plot:clue_x标签串联分散在多文档中的线索
  3. 交叉引用验证:确保重要标签在关键文档中都有适当引用

批量管理工具

  • 通过Tools > Writing Statistics查看标签使用频率
  • 使用Project > Rebuild Index修复索引不一致问题
  • 通过Search面板的高级搜索功能按标签筛选文档

高级技巧:自定义标签类型与工作流

novelWriter支持通过配置文件扩展标签类型,满足特定写作需求。例如,添加自定义@location:标签:

  1. 修改novelwriter/constants.py添加新关键词:

    nwKeyWords = SimpleNamespace(
        # ... 现有定义 ...
        LOCATION_KEY = "@location",
        VALID_KEYS = {
            # ... 现有键 ...
            "@location",
        },
        KEY_CLASS = {
            # ... 现有映射 ...
            "@location": nwItemClass.LOCATION,
        }
    )
    
  2. i18n/nw_zh_CN.ts添加本地化支持:

    {
        "keywords.location": "场景位置",
        "keywords.location.tooltip": "引用场景位置标签"
    }
    
  3. gui/doceditor.py添加图标支持:

    def _getKeywordIcon(self, keyword: str) -> QIcon:
        """Return icon for keyword type"""
        match keyword:
            # ... 现有匹配 ...
            case "@location":
                return self._theme.getIcon("location")
    

行业特定扩展示例

  • 编剧:添加@scene_int/@scene_ext区分内外景
  • RPG写作:添加@stat:标签定义角色属性
  • 学术写作:添加@citation:标签管理参考文献

性能优化:处理大型项目的标签管理

随着项目规模增长,标签数量可能达到数百甚至数千个,导致索引性能下降。以下是针对大型项目的优化策略,确保标签系统保持高效运行。

索引优化策略

增量索引更新是处理大型项目的关键。novelWriter通过indexChangedSince方法实现按需更新:

def indexChangedSince(self, checkTime: int | float) -> bool:
    """Check if index has changed since a given time"""
    return self._indexChange > float(checkTime)

优化实践

  • 禁用自动索引:在Edit > Preferences > Editor中取消勾选"实时更新索引"
  • 定期手动重建:大型编辑会话后使用Project > Rebuild Index
  • 拆分大型文档:将超过10000字的文档按章节拆分为独立文件

缓存管理

  • 定期清理缓存:删除project/.cache/index.json强制重建
  • 监控缓存大小:保持索引文件小于5MB,超过时考虑文档拆分
  • 排除临时文件:在.novelwriter配置中排除草稿文档

标签组织最佳实践

标签命名规范能显著提升大型项目的可维护性:

# 推荐的命名规范
@tag:char_arther|亚瑟王
@tag:scene_camelot|卡梅洛特城堡
@tag:item_excalibur|石中剑

# 层级组织示例
@tag:char_protagonist|主角
@tag:char_protagonist_arthur|亚瑟
@tag:char_protagonist_guinevere|桂妮薇儿

【免费下载链接】novelWriter novelWriter is an open source plain text editor designed for writing novels. It supports a minimal markdown-like syntax for formatting text. It is written with Python 3 (3.8+) and Qt 5 (5.10+) for cross-platform support. 【免费下载链接】novelWriter 项目地址: https://gitcode.com/gh_mirrors/no/novelWriter

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值