-
Notifications
You must be signed in to change notification settings - Fork 93
[203_27] 公式带前景色时,使用部分颜色时导出 LaTex 代码会出错 #3036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1588,10 +1588,10 @@ | |
|
|
||
| (define (tmtex-decode-color s . force-html) | ||
| (with cm (if (string-starts? s "#") "HTML" (named-color->xcolormap s)) | ||
| (cond ((and (== cm "none") (nnull? force-html)) | ||
| (cond ((== cm "HTML") | ||
| (string-append "#" (html-color->latex-xcolor s))) | ||
| ((and (== cm "none") (nnull? force-html)) | ||
| (tmtex-decode-color (get-hex-color s) force-html)) | ||
| ((and (== cm "HTML") (nnull? force-html)) | ||
| `((!option "HTML") ,(html-color->latex-xcolor s))) | ||
| ((== cm "texmacs") | ||
| (when (nin? s tmtex-colors) | ||
| (set! tmtex-colors (append (list s) tmtex-colors))) | ||
|
|
@@ -1607,7 +1607,7 @@ | |
| (define (tmtex-make-color val arg) | ||
| (with ltxcolor (tmtex-decode-color val #t) | ||
| (if (list? ltxcolor) | ||
| `(!group (!append (color ,@ltxcolor) ,arg)) | ||
| `(!group (!append (color ,@ltxcolor) (!group ,arg))) | ||
|
Comment on lines
1609
to
+1610
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After the refactor, The Consider either removing the dead list branch, or documenting why it is preserved as a future extension point. |
||
| `(tmcolor ,ltxcolor ,arg)))) | ||
|
|
||
| (define (post-process-math-text t) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; | ||
| ;; MODULE : 203_27.scm | ||
| ;; DESCRIPTION : Unit tests for partial color LaTeX export | ||
| ;; COPYRIGHT : (C) 2026 AcceleratorX | ||
| ;; | ||
| ;; This software falls under the GNU general public license version 3 or later. | ||
| ;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE | ||
| ;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
| ;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
|
||
| (import (liii check)) | ||
|
|
||
| (check-set-mode! 'report-failed) | ||
|
|
||
| (define (normalize-latex latex) | ||
| (set! latex (string-replace latex "\r\n" "\n")) | ||
| (set! latex (string-replace latex "\r" "")) | ||
| (set! latex (string-replace latex "\n" "")) | ||
| (set! latex (string-replace latex "\t" "")) | ||
| (string-replace latex " " "")) | ||
|
|
||
| (define (test-export-latex-partial-color) | ||
| (use-modules | ||
| (data latex) | ||
| (data tmu)) | ||
| (let* ((tmu-doc (string-load "$TEXMACS_PATH/tests/tmu/203_27.tmu")) | ||
| (latex (normalize-latex | ||
| (texmacs->latex-document (tmu->texmacs tmu-doc) '())))) | ||
| (check (string-contains? latex "\\color{red}{ddd}") => #t) | ||
| (check (string-contains? latex | ||
| (string-append "\\color{" "#" "AA6666}{ddd}")) | ||
| => #t) | ||
| (check (string-contains? latex "\\color{blue}{ddd}") => #t) | ||
| (check (string-contains? latex | ||
| (string-append "\\color[HTML]{" "AA6666}")) | ||
| => #f) | ||
| (check (string-contains? latex | ||
| (string-append "\\color{" "#" "AA6666}ddd")) | ||
| => #f))) | ||
|
|
||
| (tm-define (test_203_27) | ||
| (test-export-latex-partial-color) | ||
| (check-report)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <TMU|<tuple|1.1.0|2026.2.1-rc5>> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 测试文件只有输入,没有显示当前导出的实际 LaTeX 结果。建议补充:
|
||
|
|
||
| <style|<tuple|generic|chinese|table-captions-above|number-europe|preview-ref>> | ||
|
|
||
| <\body> | ||
| <\equation*> | ||
| <with|color|red|d d d> d d d | ||
| </equation*> | ||
|
|
||
| <\equation*> | ||
| <with|color|#a66|d d d>d d d | ||
| </equation*> | ||
|
|
||
| <\equation*> | ||
| <with|color|blue|d d d> d d d | ||
| </equation*> | ||
|
|
||
| </body> | ||
|
|
||
| <\initial> | ||
| <\collection> | ||
| <associate|page-medium|paper> | ||
| <associate|page-screen-margin|false> | ||
| </collection> | ||
| </initial> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # [203_27] 公式带前景色时,使用部分颜色时导出 LaTeX 代码会出错 | ||
|
|
||
| ## 如何测试 | ||
|
|
||
| 1. 打开测试文件 `TeXmacs/tests/tmu/203_27.tmu`,复制其中公式到 LaTeX,预期效果: | ||
| ``` | ||
| \[ {\color{red}{d d d}} d d d \] | ||
| \[ {\color{#AA6666}{d d d}} d d d \] | ||
| \[ {\color{blue}{d d d}} d d d \] | ||
| ``` | ||
|
|
||
| 原本复制到 LaTeX 效果 | ||
| ``` | ||
| \[ {\color{red}{d d d}} d d d \] | ||
| \[ {\color[HTML]{AA6666}d d d} d d d \] | ||
| \[ {\color{blue}{d d d}} d d d \] | ||
| ``` | ||
|
|
||
| 2. 集成测试文件在 `TeXmacs/tests/203_27.scm` | ||
| ``` | ||
| xmake run 203_27 | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force-htmlguard removed from HTML branch — silent behavior change forcolorbox/fcolorbox/ornament-colorPreviously the HTML case was gated on
(nnull? force-html), so callers that pass noforce-htmlargument (lines 2371, 2374, 2699 — used for\colorbox,\fcolorbox, andornament-color) would fall through to theelsebranch 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-htmlvariadic parameter now has no effect on the HTML path at all — only thenonerecursion still consults it. Consider renaming it toforce-expandor adding a comment documenting that its scope has narrowed, to prevent future confusion.