Skip to content

[0600] 修复 smart-ref 对 corollary 和 assumption 无效的问题#3304

Merged
JackYansongLi merged 3 commits into
mainfrom
jl/corollary
May 9, 2026
Merged

[0600] 修复 smart-ref 对 corollary 和 assumption 无效的问题#3304
JackYansongLi merged 3 commits into
mainfrom
jl/corollary

Conversation

@JackYansongLi
Copy link
Copy Markdown
Contributor

@JackYansongLi JackYansongLi commented May 9, 2026

[0600] 修复 smart-ref 对 corollary 和 assumption 无效的问题

如何测试

打开 TeXmacs/tests/tmu/0600.tmu,查看 smart-ref 和 typed ref 的渲染是否正确:

  • <smart-ref|corollary:test1> 应显示为 "Corollary 1"
  • <smart-ref|cor:test2> 应显示为 "Corollary 2"
  • <corollary-ref|corollary:test1> 应显示为 "Corollary 1"
  • <smart-ref|assumption:test1> 应显示为 "Assumption 1"
  • <smart-ref|ass:test2> 应显示为 "Assumption 2"
  • <assumption-ref|assumption:test1> 应显示为 "Assumption 1"

2026/05/09

What

修复 smart-refcorollaryassumption 环境无效的问题。

当 label 以 corollary:assumption: 等完整环境名作为前缀时,smart-ref 无法识别对应的类型,导致引用只显示编号而不显示类型名称(如只显示 "1" 而不是 "Corollary 1")。

Why

smart-ref 系统通过检查当前样式中是否存在 <prefix>-ref 宏来推断引用类型。在 smart-ref.ts 中:

  • corollary 只定义了 co-refcor-refcorr-ref 和拼写错误的 corrolary-ref,缺少正确的 corollary-ref
  • assumption 完全没有定义任何对应的 typed ref 宏(如 ass-refassumption-ref

因此当用户将 label 命名为 corollary:xxxassumption:xxx 时,smart-ref-type 无法匹配到对应的宏,回退为 unknown 类型,导致只显示纯编号。

How

TeXmacs/packages/utilities/smart-ref.ts 中补充缺失的宏定义:

  1. 在 corollary 段添加 <assign|corollary-ref|...>
  2. 在 axiom 段之后添加 <assign|ass-ref|...><assign|assumption-ref|...>

同时保留已有的拼写错误 corrolary-ref 以保持向后兼容。

- Add missing corollary-ref macro in smart-ref.ts
- Add ass-ref and assumption-ref macros
- Keep corrolary-ref for backward compatibility
- Add test file TeXmacs/tests/tmu/0600.tmu
- Add devel doc devel/0600.md
- 在 smart-ref.ts 中补充缺失的 corollary-ref 宏
- 新增 ass-ref 和 assumption-ref 宏,支持 assumption 环境
- 保留 corrolary-ref 保持向后兼容
- 新增测试文件 TeXmacs/tests/tmu/0600.tmu
- 新增开发文档 devel/0600.md
@JackYansongLi JackYansongLi changed the title [0600] Fix smart-ref for corollary and add assumption support [0600] 修复 smart-ref 对 corollary 和 assumption 无效的问题 May 9, 2026
Copy link
Copy Markdown
Contributor

@Yuki-Nagori Yuki-Nagori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JackYansongLi JackYansongLi merged commit f76be30 into main May 9, 2026
@JackYansongLi JackYansongLi deleted the jl/corollary branch May 9, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants