[203_27] 公式带前景色时,使用部分颜色时导出 LaTex 代码会出错#3036
Conversation
| @@ -0,0 +1,40 @@ | |||
| <TMU|<tuple|1.1.0|2026.2.1-rc5>> | |||
There was a problem hiding this comment.
测试文件只有输入,没有显示当前导出的实际 LaTeX 结果。建议补充:
- 当前 PR 修复后,导出 LaTeX 的实际结果是什么
- 与修复前的对比
Greptile SummaryThis PR fixes a LaTeX export bug where formulas using partial (hex) foreground colors were emitted as Key changes:
Notes:
Confidence Score: 4/5Safe to merge; the fix is correct and well-tested, with only minor dead-code and documentation nits remaining. The core logic change is sound: HTML colors now route through the Both Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["tmtex-make-color(val, arg)"] --> B["tmtex-decode-color(val, #t)"]
B --> C{cm = ?}
C -- "HTML (s starts with #)" --> D["string-append '#' html-color->latex-xcolor(s) → '#AA6666' (string)"]
C -- "none + force-html" --> E["recursive call with get-hex-color(s)"]
C -- "texmacs" --> F["string-replace s ' ' '' → named string"]
C -- "x11names" --> G["recursive call with get-hex-color(s)"]
C -- "else" --> H["string-replace s ' ' '' → named/colormap string"]
D --> I{list? ltxcolor}
F --> I
H --> I
I -- "true (DEAD CODE after fix)" --> J["(!group (!append (color ...) (!group arg))) → {\\color[...]{...}{arg}}"]
I -- "false (ALL paths now)" --> K["(tmcolor ltxcolor arg)"]
K --> L["tmcolor macro expands to {\\color{ltxcolor}{arg}}"]
Reviews (1): Last reviewed commit: "测试用例" | Re-trigger Greptile |
| (if (list? ltxcolor) | ||
| `(!group (!append (color ,@ltxcolor) ,arg)) | ||
| `(!group (!append (color ,@ltxcolor) (!group ,arg))) |
There was a problem hiding this comment.
Dead code branch after the HTML-path change
After the refactor, tmtex-decode-color always returns a string — the "HTML" branch now returns (string-append "#" ...), and every other branch also returns a string or recurses (which also now returns a string). Therefore (list? ltxcolor) is always #f, and the (!group (!append (color ,@ltxcolor) (!group ,arg))) line can never be reached.
The (!group ,arg) addition that was part of this PR's fix is consequently also dead code. If the grouping fix is needed, it should be applied to the active code path (the else branch via tmcolor), although the tmcolor macro definition already wraps arg in (!group 2) — so grouping is already handled there.
Consider either removing the dead list branch, or documenting why it is preserved as a future extension point.
| (cond ((== cm "HTML") | ||
| (string-append "#" (html-color->latex-xcolor s))) |
There was a problem hiding this comment.
force-html guard removed from HTML branch — silent behavior change for colorbox/fcolorbox/ornament-color
Previously the HTML case was gated on (nnull? force-html), so callers that pass no force-html argument (lines 2371, 2374, 2699 — used for \colorbox, \fcolorbox, and ornament-color) would fall through to the else branch and return the raw string (e.g. "#a66") unchanged. Now those callers also receive the normalized "#AA6666" form.
This is probably an improvement (the normalized 6-digit hex is more portable with xcolor), but it is an unintentional side effect. The force-html variadic parameter now has no effect on the HTML path at all — only the none recursion still consults it. Consider renaming it to force-expand or adding a comment documenting that its scope has narrowed, to prevent future confusion.
No description provided.