From c4fd6e9d1c5a22077364712d1f4226d434c575fd Mon Sep 17 00:00:00 2001 From: jackyansongli Date: Fri, 5 Jun 2026 11:35:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[0621]=20=E4=BB=BF=E7=85=A7=20eqnarray=20?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E9=80=BB=E8=BE=91=E6=94=AF=E6=8C=81=20align?= =?UTF-8?q?=20=E7=8E=AF=E5=A2=83=20HTML=20=E5=AF=BC=E5=87=BA=E4=B8=8E?= =?UTF-8?q?=E5=8F=8C=E5=90=91=E6=97=A0=E6=8D=9F=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/packages/environment/env-math.ts | 8 + .../html/progs/convert/html/htmltm.scm | 34 +- .../html/progs/convert/html/tmhtml.scm | 48 +- TeXmacs/progs/init-research.scm | 766 ++++++++++++------ TeXmacs/tests/0621.scm | 117 +++ TeXmacs/tests/html/0621_import_test.html | 18 + TeXmacs/tests/tmu/0621.tmu | 41 + 7 files changed, 752 insertions(+), 280 deletions(-) create mode 100644 TeXmacs/tests/0621.scm create mode 100644 TeXmacs/tests/html/0621_import_test.html create mode 100644 TeXmacs/tests/tmu/0621.tmu diff --git a/TeXmacs/packages/environment/env-math.ts b/TeXmacs/packages/environment/env-math.ts index ee3732cc2d..c786f00281 100644 --- a/TeXmacs/packages/environment/env-math.ts +++ b/TeXmacs/packages/environment/env-math.ts @@ -232,8 +232,16 @@ > + + <\rclx-base> + |||||||>|||||||||> + + > + >>> + >>> + \; diff --git a/TeXmacs/plugins/html/progs/convert/html/htmltm.scm b/TeXmacs/plugins/html/progs/convert/html/htmltm.scm index e413dd9a04..9642d57772 100644 --- a/TeXmacs/plugins/html/progs/convert/html/htmltm.scm +++ b/TeXmacs/plugins/html/progs/convert/html/htmltm.scm @@ -92,23 +92,39 @@ ;; Tables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define (htmltm-table env a c) +(tm-define (htmltm-table env a c) ;; TODO: support @lang attributes ;; NOT SUPPORTED: @summary - for spoken rendering ;; @title - no tooltip feature ;; @style - no CSS support ;; @events - no event support - (let ((cells (table-cells env a c))) + (let* ((class-value (shtml-attr-non-null a 'class)) (cells (table-cells env a c))) (if (null? cells) '() - ((cut table-align env a <>) - (append (list (tmtable->stm (tmtable (table-formats env a c) cells))) - (table-label env a) - ) ;append - ) ; + (let* ((tbl-stm (tmtable->stm (tmtable (table-formats env a c) cells))) + (stms (append (list tbl-stm) (table-label env a))) + (aligned ((cut table-align env a <>) stms)) + ) ; + (cond ((and (string? class-value) + (in? class-value + '("eqnarray" + "eqnarray*" + "align" + "align*" + "gather" + "gather*" + "multline" + "multline*") + ) ;in? + ) ;and + (list `(,(string->symbol class-value) (document ,tbl-stm))) + ) ; + (else aligned) + ) ;cond + ) ;let* ) ;if - ) ;let -) ;define + ) ;let* +) ;tm-define (define (table-label env a) (let ((label (xmltm-attr->label a 'id))) diff --git a/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm b/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm index 85ab19d270..f1a086f393 100644 --- a/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm +++ b/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm @@ -31,13 +31,13 @@ (define tmhtml-env (make-ahash-table)) -(define tmhtml-css? #t) +(tm-define tmhtml-css? #t) -(define tmhtml-mathjax? #f) +(tm-define tmhtml-mathjax? #f) -(define tmhtml-mathml? #f) +(tm-define tmhtml-mathml? #f) -(define tmhtml-images? #f) +(tm-define tmhtml-images? #f) (tm-define tmhtml-base64? #t) (define tmhtml-image-serial 0) @@ -2397,6 +2397,46 @@ ) ;if ) ;tm-define +(tm-define (rewrite-align* t) + (cond ((tm-atomic? t) t) + ((tm-func? t 'row 2) + (let* ((l (tm-ref t 0 0)) (r (split-htab (tm-ref t 1 0)))) + `(row (cell (big-math ,l)) + (cell (big-math ,(car r))) + (cell ,(cadr r))) + ) ;let* + ) ; + (else (cons (tm-label t) (map rewrite-align* (tm-children t)))) + ) ;cond +) ;tm-define + +(tm-define (ext-tmhtml-align* body) + (:secure #t) + (if (tm-func? body 'document 1) + `(document ,(ext-tmhtml-align* (tm-ref body 0))) + (cond ((null? (tm-search body (lambda (x) (tm-func? x 'htab)))) + `(equation* (aligned* ,body)) + ) ; + ((and (tm-func? body 'tformat) + (tm-func? (tm-ref body :last) 'table 1) + (tm-func? (tm-ref body :last 0) 'row 2) + ) ;and + (let* ((row (tm-ref body :last 0)) + (l (tm-ref row 0 0)) + (r (split-htab (tm-ref row 1 0))) + (row1 `(row (cell ,l) (cell ,(car r)))) + (rcl `(aligned* (tformat (table ,row1)))) + (row2 `(row (cell (big-math ,rcl)) (cell ,(cadr r)))) + (res `(cx-table (tformat (table ,row2)))) + ) ; + res + ) ;let* + ) ; + (else `(alignx-table ,(rewrite-align* body))) + ) ;cond + ) ;if +) ;tm-define + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Tags for customized html generation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/TeXmacs/progs/init-research.scm b/TeXmacs/progs/init-research.scm index ed44732d3a..7095351a59 100644 --- a/TeXmacs/progs/init-research.scm +++ b/TeXmacs/progs/init-research.scm @@ -13,6 +13,7 @@ ;; S7 macros are not usual macros... + (define define-macro define-expansion) (define primitive-symbol? symbol?) @@ -29,72 +30,112 @@ (define primitive-load load) (define primitive-eval eval) (define primitive-catch catch) - + (varlet (rootlet) 'tm-eval (lambda (obj) (eval obj *texmacs-user-module*))) - (set! load (lambda (file . env) (primitive-load file (if (null? env) *current-module* (car env))))) - (set! eval (lambda (obj . env) - (let ((res (primitive-eval obj (if (null? env) *current-module* (car env))))) - ;;(format #t "Eval: ~A -> ~A\n" obj res) - res) - )) - - (set! catch (lambda ( key cl hdl ) - (primitive-catch key cl - (lambda args - (apply hdl (car args) "[not-implemented]" (caadr args) (list (cdadr args))))))) - ) + (set! load + (lambda (file . env) + (primitive-load file (if (null? env) *current-module* (car env))) + ) ;lambda + ) ;set! + (set! eval + (lambda (obj . env) + (let ((res (primitive-eval obj (if (null? env) *current-module* (car env))))) + ;; (format #t "Eval: ~A -> ~A\n" obj res) + res + ) ;let + ) ;lambda + ) ;set! + + (set! catch + (lambda (key cl hdl) + (primitive-catch key + cl + (lambda args + (apply hdl (car args) "[not-implemented]" (caadr args) (list (cdadr args))) + ) ;lambda + ) ;primitive-catch + ) ;lambda + ) ;set! +) ;let (let () (display "Benchmark 1\n") (define start (texmacs-time)) - (define (fib n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))) + (define (fib n) + (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))) + ) ;define (display (fib 30)) (newline) - (display "Time: ") (display (- (texmacs-time) start)) (newline) -) + (display "Time: ") + (display (- (texmacs-time) start)) + (newline) +) ;let (define developer-mode? #f) + (define boot-start (texmacs-time)) + (define remote-client-list (list)) (display "Booting TeXmacs kernel functionality\n") (load (url-concretize "$TEXMACS_PATH/progs/kernel/boot/boot-s7.scm")) -(inherit-modules (kernel boot compat-s7) (kernel boot abbrevs) - (kernel boot debug) (kernel boot srfi) - (kernel boot ahash-table) (kernel boot prologue)) -(inherit-modules (kernel library base) (kernel library list) - (kernel library tree) (kernel library content) - (kernel library patch)) +(inherit-modules (kernel boot compat-s7) + (kernel boot abbrevs) + (kernel boot debug) + (kernel boot srfi) + (kernel boot ahash-table) + (kernel boot prologue) +) ;inherit-modules +(inherit-modules (kernel library base) + (kernel library list) + (kernel library tree) + (kernel library content) + (kernel library patch) +) ;inherit-modules (inherit-modules (kernel regexp regexp-match) (kernel regexp regexp-select)) -(inherit-modules (kernel logic logic-rules) (kernel logic logic-query) - (kernel logic logic-data)) +(inherit-modules (kernel logic logic-rules) + (kernel logic logic-query) + (kernel logic logic-data) +) ;inherit-modules (inherit-modules (kernel texmacs tm-define) - (kernel texmacs tm-preferences) (kernel texmacs tm-modes) - (kernel texmacs tm-plugins) (kernel texmacs tm-secure) - (kernel texmacs tm-convert) (kernel texmacs tm-dialogue) - (kernel texmacs tm-language) (kernel texmacs tm-file-system) - (kernel texmacs tm-states)) + (kernel texmacs tm-preferences) + (kernel texmacs tm-modes) + (kernel texmacs tm-plugins) + (kernel texmacs tm-secure) + (kernel texmacs tm-convert) + (kernel texmacs tm-dialogue) + (kernel texmacs tm-language) + (kernel texmacs tm-file-system) + (kernel texmacs tm-states) +) ;inherit-modules (inherit-modules (kernel gui gui-markup) - (kernel gui menu-define) (kernel gui menu-widget) - (kernel gui kbd-define) (kernel gui kbd-handlers) - (kernel gui menu-test) - (kernel old-gui old-gui-widget) - (kernel old-gui old-gui-factory) - (kernel old-gui old-gui-form) - (kernel old-gui old-gui-test)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting utilities\n") + (kernel gui menu-define) + (kernel gui menu-widget) + (kernel gui kbd-define) + (kernel gui kbd-handlers) + (kernel gui menu-test) + (kernel old-gui old-gui-widget) + (kernel old-gui old-gui-factory) + (kernel old-gui old-gui-form) + (kernel old-gui old-gui-test) +) ;inherit-modules +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting utilities\n") (use-modules (utils library cpp-wrap)) (lazy-define (utils library cursor) notify-cursor-moved) (lazy-define (utils edit variants) make-inline-tag-list make-wrapped-tag-list) (lazy-define (utils cas cas-out) cas->stree) (lazy-define (utils plugins plugin-cmd) pre-serialize verbatim-serialize) -(lazy-define (utils test test-convert) delayed-quit - build-manual build-ref-suite run-test-suite) +(lazy-define (utils test test-convert) + delayed-quit + build-manual + build-ref-suite + run-test-suite +) ;lazy-define (use-modules (utils library smart-table)) (use-modules (utils plugins plugin-convert)) (use-modules (utils misc markup-funcs)) @@ -103,24 +144,34 @@ (lazy-define (utils automate auto-tmfs) auto-load-help) (lazy-define (utils misc gui-keyboard) get-keyboard) (lazy-keyboard (utils automate auto-kbd) in-auto?) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting BibTeX style modules\n") +;; (display "Booting BibTeX style modules\n") (use-modules (bibtex bib-utils)) (lazy-define (bibtex bib-complete) current-bib-file citekey-completions) (lazy-menu (bibtex bib-widgets) open-bibliography-inserter) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting main TeXmacs functionality\n") -(use-modules (texmacs texmacs tm-server) (texmacs texmacs tm-view) - (texmacs texmacs tm-files) (texmacs texmacs tm-print)) +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting main TeXmacs functionality\n") +(use-modules (texmacs texmacs tm-server) + (texmacs texmacs tm-view) + (texmacs texmacs tm-files) + (texmacs texmacs tm-print) +) ;use-modules (use-modules (texmacs keyboard config-kbd)) (lazy-keyboard (texmacs keyboard prefix-kbd) always?) -(lazy-menu (texmacs menus file-menu) file-menu go-menu - new-file-menu load-menu save-menu - print-menu print-menu-inline close-menu) +(lazy-menu (texmacs menus file-menu) + file-menu + go-menu + new-file-menu + load-menu + save-menu + print-menu + print-menu-inline + close-menu +) ;lazy-menu (lazy-menu (texmacs menus edit-menu) edit-menu) (lazy-menu (texmacs menus view-menu) view-menu texmacs-bottom-toolbars) (lazy-menu (texmacs menus tools-menu) tools-menu) @@ -134,48 +185,94 @@ (lazy-define (texmacs menus file-menu) recent-file-list recent-directory-list) (lazy-define (texmacs menus view-menu) set-bottom-bar test-bottom-bar?) (tm-define (notify-set-attachment name key val) (noop)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting generic mode\n") +;; (display "Booting generic mode\n") (lazy-keyboard (generic generic-kbd) always?) (lazy-menu (generic generic-menu) focus-menu texmacs-focus-icons) -(lazy-menu (generic format-menu) format-menu - font-size-menu color-menu horizontal-space-menu - transform-menu specific-menu - text-font-effects-menu text-effects-menu - vertical-space-menu indentation-menu line-break-menu - page-header-menu page-footer-menu page-numbering-menu - page-break-menu) -(lazy-menu (generic document-menu) document-menu - project-menu document-style-menu global-language-menu) +(lazy-menu (generic format-menu) + format-menu + font-size-menu + color-menu + horizontal-space-menu + transform-menu + specific-menu + text-font-effects-menu + text-effects-menu + vertical-space-menu + indentation-menu + line-break-menu + page-header-menu + page-footer-menu + page-numbering-menu + page-break-menu +) ;lazy-menu +(lazy-menu (generic document-menu) + document-menu + project-menu + document-style-menu + global-language-menu +) ;lazy-menu (lazy-menu (generic document-part) - preamble-menu document-part-menu project-manage-menu) -(lazy-menu (generic insert-menu) insert-menu texmacs-insert-menu - texmacs-insert-icons insert-link-menu insert-image-menu) -(lazy-define (generic document-edit) update-document - get-init-page-rendering init-page-rendering) + preamble-menu + document-part-menu + project-manage-menu +) ;lazy-menu +(lazy-menu (generic insert-menu) + insert-menu + texmacs-insert-menu + texmacs-insert-icons + insert-link-menu + insert-image-menu +) ;lazy-menu +(lazy-define (generic document-edit) + update-document + get-init-page-rendering + init-page-rendering +) ;lazy-define (lazy-define (generic generic-edit) notify-activated notify-disactivated) (lazy-define (generic generic-doc) focus-help) -(lazy-define (generic search-widgets) search-toolbar replace-toolbar - open-search toolbar-search-start interactive-search - open-replace toolbar-replace-start interactive-replace - search-next-match) +(lazy-define (generic search-widgets) + search-toolbar + replace-toolbar + open-search + toolbar-search-start + interactive-search + open-replace + toolbar-replace-start + interactive-replace + search-next-match +) ;lazy-define (lazy-keyboard (generic search-kbd)) -(lazy-define (generic spell-widgets) spell-toolbar - open-spell toolbar-spell-start interactive-spell) +(lazy-define (generic spell-widgets) + spell-toolbar + open-spell + toolbar-spell-start + interactive-spell +) ;lazy-define (lazy-define (generic format-widgets) open-paragraph-format open-page-format) -(lazy-define (generic pattern-selector) open-pattern-selector - open-gradient-selector open-background-picture-selector) -(lazy-define (generic document-widgets) open-source-tree-preferences - open-document-paragraph-format open-document-page-format - open-document-metadata open-document-colors - open-page-headers-footers open-document-page-number) +(lazy-define (generic pattern-selector) + open-pattern-selector + open-gradient-selector + open-background-picture-selector +) ;lazy-define +(lazy-define (generic document-widgets) + open-source-tree-preferences + open-document-paragraph-format + open-document-page-format + open-document-metadata + open-document-colors + open-page-headers-footers + open-document-page-number +) ;lazy-define (tm-property (open-search) (:interactive #t)) (tm-property (open-replace) (:interactive #t)) (tm-property (open-paragraph-format) (:interactive #t)) -(tm-property (open-page-format) (:interactive #t) - (:applicable (not (selection-active?)))) +(tm-property (open-page-format) + (:interactive #t) + (:applicable (not (selection-active?))) +) ;tm-property (tm-property (open-source-tree-preferences) (:interactive #t)) (tm-property (open-document-paragraph-format) (:interactive #t)) (tm-property (open-document-page-format) (:interactive #t)) @@ -186,49 +283,79 @@ (tm-property (open-pattern-selector cmd w) (:interactive #t)) (tm-property (open-gradient-selector cmd) (:interactive #t)) (tm-property (open-background-picture-selector cmd) (:interactive #t)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting text mode\n") +;; (display "Booting text mode\n") (lazy-keyboard (text text-kbd) in-text?) (lazy-keyboard (text text-kbd-utf8) in-text?) -(lazy-menu (text text-menu) text-format-menu text-format-icons - text-menu text-block-menu text-inline-menu - text-icons text-block-icons text-inline-icons) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting math mode\n") +(lazy-menu (text text-menu) + text-format-menu + text-format-icons + text-menu + text-block-menu + text-inline-menu + text-icons + text-block-icons + text-inline-icons +) ;lazy-menu +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting math mode\n") (lazy-keyboard (math math-kbd) in-math?) (lazy-keyboard (math math-sem-edit) in-sem-math?) -(lazy-menu (math math-menu) math-format-menu math-format-icons - math-menu math-insert-menu - math-icons math-insert-icons - math-correct-menu semantic-math-preferences-menu - context-preferences-menu insert-math-menu) +(lazy-menu (math math-menu) + math-format-menu + math-format-icons + math-menu + math-insert-menu + math-icons + math-insert-icons + math-correct-menu + semantic-math-preferences-menu + context-preferences-menu + insert-math-menu +) ;lazy-menu (lazy-initialize (math math-menu) (in-math?)) (lazy-define (math math-edit) brackets-refresh) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting programming modes\n") +;; (display "Booting programming modes\n") (lazy-keyboard (prog prog-kbd) in-prog?) -(lazy-menu (prog prog-menu) prog-format-menu prog-format-icons - prog-menu prog-icons) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting source mode\n") +(lazy-menu (prog prog-menu) + prog-format-menu + prog-format-icons + prog-menu + prog-icons +) ;lazy-menu +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting source mode\n") (lazy-keyboard (source source-kbd) always?) -(lazy-menu (source source-menu) source-macros-menu source-menu source-icons - source-transformational-menu source-executable-menu) +(lazy-menu (source source-menu) + source-macros-menu + source-menu + source-icons + source-transformational-menu + source-executable-menu +) ;lazy-menu (lazy-define (source macro-edit) - has-macro-source? edit-macro-source edit-focus-macro-source) + has-macro-source? + edit-macro-source + edit-focus-macro-source +) ;lazy-define (lazy-menu (source macro-menu) insert-macro-menu) (lazy-define (source macro-widgets) - editable-macro? open-macros-editor - open-macro-editor create-table-macro - edit-focus-macro edit-previous-macro) + editable-macro? + open-macros-editor + open-macro-editor + create-table-macro + edit-focus-macro + edit-previous-macro +) ;lazy-define (lazy-define (source shortcut-edit) init-user-shortcuts has-user-shortcut?) (lazy-define (source shortcut-widgets) open-shortcuts-editor) (tm-property (open-macro-editor l mode) (:interactive #t)) @@ -236,89 +363,150 @@ (tm-property (open-macros-editor mode) (:interactive #t)) (tm-property (edit-focus-macro) (:interactive #t)) (tm-property (open-shortcuts-editor . opt) (:interactive #t)) -(when (url-exists? "") (delayed (:idle 100) (init-user-shortcuts))) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +(when (url-exists? "") + (delayed (:idle 100) (init-user-shortcuts)) +) ;when +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting table mode\n") +;; (display "Booting table mode\n") (lazy-keyboard (table table-kbd) in-table?) (lazy-menu (table table-menu) insert-table-menu) (lazy-define (table table-edit) table-resize-notify) (lazy-define (table table-widgets) open-cell-properties open-table-properties) (tm-property (open-cell-properties) (:interactive #t)) (tm-property (open-table-properties) (:interactive #t)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting graphics mode\n") +;; (display "Booting graphics mode\n") (lazy-keyboard (graphics graphics-kbd) in-active-graphics?) (lazy-menu (graphics graphics-menu) graphics-menu graphics-icons) (lazy-define (graphics graphics-object) - graphics-init-state graphics-decorations-update) + graphics-init-state + graphics-decorations-update +) ;lazy-define (lazy-define (graphics graphics-utils) make-graphics) (lazy-define (graphics graphics-edit) - graphics-busy? - graphics-reset-context graphics-undo-enabled - graphics-release-left graphics-release-middle - graphics-release-right graphics-start-drag-left - graphics-dragging-left graphics-end-drag-left) -(lazy-define (graphics graphics-main) graphics-update-proviso - graphics-get-proviso graphics-set-proviso) -(lazy-define (graphics graphics-markup) arrow-with-text arrow-with-text* circle three-points-circle std-arc std-arc-counterclockwise three-points-arc sector sector-counterclockwise) -(define-secure-symbols arrow-with-text arrow-with-text* circle three-points-circle std-arc std-arc-counterclockwise three-points-arc sector sector-counterclockwise) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting formal and natural languages\n") + graphics-busy? + graphics-reset-context + graphics-undo-enabled + graphics-release-left + graphics-release-middle + graphics-release-right + graphics-start-drag-left + graphics-dragging-left + graphics-end-drag-left +) ;lazy-define +(lazy-define (graphics graphics-main) + graphics-update-proviso + graphics-get-proviso + graphics-set-proviso +) ;lazy-define +(lazy-define (graphics graphics-markup) + arrow-with-text + arrow-with-text* + circle + three-points-circle + std-arc + std-arc-counterclockwise + three-points-arc + sector + sector-counterclockwise +) ;lazy-define +(define-secure-symbols arrow-with-text + arrow-with-text* + circle + three-points-circle + std-arc + std-arc-counterclockwise + three-points-arc + sector + sector-counterclockwise +) ;define-secure-symbols +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting formal and natural languages\n") (lazy-language (language minimal) minimal) (lazy-language (language std-math) std-math) (lazy-define (language natural) replace) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting educational features\n") +;; (display "Booting educational features\n") (lazy-keyboard (education edu-kbd) in-edu-text?) (lazy-menu (education edu-menu) edu-insert-menu) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting dynamic features\n") +;; (display "Booting dynamic features\n") (lazy-keyboard (dynamic fold-kbd) always?) (lazy-keyboard (dynamic scripts-kbd) always?) (lazy-keyboard (dynamic calc-kbd) always?) -(lazy-menu (dynamic fold-menu) insert-fold-menu dynamic-menu dynamic-icons - graphics-overlays-menu graphics-screens-menu - graphics-focus-overlays-menu graphics-focus-overlays-icons) +(lazy-menu (dynamic fold-menu) + insert-fold-menu + dynamic-menu + dynamic-icons + graphics-overlays-menu + graphics-screens-menu + graphics-focus-overlays-menu + graphics-focus-overlays-icons +) ;lazy-menu (lazy-menu (dynamic session-menu) insert-session-menu session-help-icons) -(lazy-menu (dynamic scripts-menu) scripts-eval-menu scripts-plot-menu - plugin-eval-menu plugin-eval-toggle-menu plugin-plot-menu) -(lazy-menu (dynamic calc-menu) calc-table-menu calc-insert-menu - calc-icourse-menu) +(lazy-menu (dynamic scripts-menu) + scripts-eval-menu + scripts-plot-menu + plugin-eval-menu + plugin-eval-toggle-menu + plugin-plot-menu +) ;lazy-menu +(lazy-menu (dynamic calc-menu) + calc-table-menu + calc-insert-menu + calc-icourse-menu +) ;lazy-menu (lazy-menu (dynamic animate-menu) insert-animation-menu animate-toolbar) (lazy-define (dynamic fold-edit) - screens-switch-to dynamic-make-slides overlays-context?) + screens-switch-to + dynamic-make-slides + overlays-context? +) ;lazy-define (lazy-define (dynamic session-edit) scheme-eval) (lazy-define (dynamic calc-edit) calc-ready? calc-table-renumber) (lazy-define (dynamic scripts-plot) open-plots-editor) (lazy-initialize (dynamic session-menu) (in-session?)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting documentation\n") +;; (display "Booting documentation\n") (lazy-keyboard (doc tmdoc-kbd) in-manual?) (lazy-keyboard (doc apidoc-kbd) developer-mode?) (lazy-menu (doc tmdoc-menu) tmdoc-menu tmdoc-icons) (lazy-menu (doc help-menu) help-menu) -(lazy-define (doc tmdoc) tmdoc-expand-help tmdoc-expand-help-manual - tmdoc-expand-this tmdoc-include) +(lazy-define (doc tmdoc) + tmdoc-expand-help + tmdoc-expand-help-manual + tmdoc-expand-this + tmdoc-include +) ;lazy-define (use-modules (doc docgrep)) -(lazy-define (doc tmdoc-search) tmdoc-search-style tmdoc-search-tag - tmdoc-search-parameter tmdoc-search-scheme) -(lazy-define (doc tmweb) youtube-select - tmweb-convert-dir tmweb-update-dir - tmweb-convert-dir-keep-texmacs tmweb-update-dir-keep-texmacs - tmweb-interactive-build tmweb-interactive-update - open-website-builder) +(lazy-define (doc tmdoc-search) + tmdoc-search-style + tmdoc-search-tag + tmdoc-search-parameter + tmdoc-search-scheme +) ;lazy-define +(lazy-define (doc tmweb) + youtube-select + tmweb-convert-dir + tmweb-update-dir + tmweb-convert-dir-keep-texmacs + tmweb-update-dir-keep-texmacs + tmweb-interactive-build + tmweb-interactive-update + open-website-builder +) ;lazy-define (lazy-define (doc apidoc) apidoc-all-modules apidoc-all-symbols) (lazy-menu (doc apidoc-menu) apidoc-menu) (lazy-tmfs-handler (doc docgrep) grep) @@ -326,19 +514,15 @@ (lazy-tmfs-handler (doc apidoc) apidoc) (define-secure-symbols tmdoc-include youtube-select) (tm-property (open-website-builder) (:interactive #t)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting converters\n") +;; (display "Booting converters\n") -; Source Code data (lazy-format (data code) cpp scheme) (lazy-format (data csv) csv) -; Image data -(lazy-format (data image) - postscript pdf svg - gif jpeg png ppm tif webp xpm) +(lazy-format (data image) postscript pdf svg gif jpeg png ppm tif webp xpm) (lazy-format (convert rewrite init-rewrite) texmacs verbatim) (lazy-format (data mgs) mgs) @@ -347,138 +531,174 @@ (lazy-format (data docx) docx) (lazy-format (data html) html) (lazy-define (convert images tmimage) - export-selection-as-graphics clipboard-copy-image) + export-selection-as-graphics + clipboard-copy-image +) ;lazy-define (lazy-define (convert rewrite init-rewrite) texmacs->code texmacs->verbatim) -(lazy-define (convert html tmhtml) ext-tmhtml-eqnarray*) -(define-secure-symbols ext-tmhtml-eqnarray*) +(lazy-define (convert html tmhtml) ext-tmhtml-eqnarray* ext-tmhtml-align*) +(define-secure-symbols ext-tmhtml-eqnarray* ext-tmhtml-align*) (lazy-define (convert html tmhtml-expand) tmhtml-env-patch) (lazy-define (convert latex latex-drd) latex-arity latex-type) (lazy-define (convert latex tmtex) tmtex-env-patch) -(lazy-define (convert latex latex-tools) latex-set-virtual-packages - latex-has-style? latex-has-package? - latex-has-texmacs-style? latex-has-texmacs-package?) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting partial document facilities\n") +(lazy-define (convert latex latex-tools) + latex-set-virtual-packages + latex-has-style? + latex-has-package? + latex-has-texmacs-style? + latex-has-texmacs-package? +) ;lazy-define +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting partial document facilities\n") (lazy-define (part part-shared) buffer-initialize buffer-notify) (lazy-menu (part part-menu) document-master-menu) (lazy-tmfs-handler (part part-tmfs) part) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting database facilities\n") +;; (display "Booting database facilities\n") (lazy-define (database db-widget) open-db-chooser) (lazy-define (database db-menu) db-show-toolbar) (lazy-define (database db-convert) db-url?) (lazy-define (database bib-db) zealous-bib-import zealous-bib-export) (lazy-define (database bib-manage) - bib-import-bibtex bib-compile bib-attach open-bib-chooser) + bib-import-bibtex + bib-compile + bib-attach + open-bib-chooser +) ;lazy-define (lazy-define (database bib-local) open-biblio) (lazy-menu (database db-menu) db-menu db-toolbar) (lazy-tmfs-handler (database db-tmfs) db) (lazy-keyboard (database bib-kbd) in-bib?) (tm-property (open-biblio) (:interactive #t)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting remote facilities\n") +;; (display "Booting remote facilities\n") (lazy-define (client client-tmfs) remote-home-directory) (lazy-menu (server server-menu) start-server-menu server-menu) -(lazy-menu (client client-menu) start-client-menu client-menu - remote-menu remote-icons) +(lazy-menu (client client-menu) + start-client-menu + client-menu + remote-menu + remote-icons +) ;lazy-menu (lazy-tmfs-handler (client client-tmfs) remote-file) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting linking facilities\n") +;; (display "Booting linking facilities\n") (lazy-menu (link link-menu) link-menu) (lazy-keyboard (link link-kbd) with-linking-tool?) (lazy-define (link link-edit) create-unique-id) -(lazy-define (link link-navigate) link-active-upwards link-active-ids - link-follow-ids) -(lazy-define (link link-extern) get-constellation - get-link-locations register-link-locations) +(lazy-define (link link-navigate) + link-active-upwards + link-active-ids + link-follow-ids +) ;lazy-define +(lazy-define (link link-extern) + get-constellation + get-link-locations + register-link-locations +) ;lazy-define (lazy-menu (link ref-menu) ref-menu) (lazy-define (link ref-edit) preview-reference) (define-secure-symbols preview-reference) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting versioning facilities\n") +;; (display "Booting versioning facilities\n") (lazy-menu (version version-menu) version-menu) (lazy-keyboard (version version-kbd) with-versioning-tool?) (lazy-define (version version-tmfs) update-buffer commit-buffer) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting debugging and developer facilities\n") +;; (display "Booting debugging and developer facilities\n") (lazy-menu (debug debug-menu) debug-menu) (lazy-menu (texmacs menus developer-menu) - developer-menu custom-keyboard-toolbar) -(lazy-define (debug debug-widgets) notify-debug-message - open-debug-console open-error-messages) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting editing modes for various special styles\n") + developer-menu + custom-keyboard-toolbar +) ;lazy-menu +(lazy-define (debug debug-widgets) + notify-debug-message + open-debug-console + open-error-messages +) ;lazy-define +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting editing modes for various special styles\n") (lazy-menu (various poster-menu) poster-block-menu) (lazy-menu (various theme-menu) basic-theme-menu) (lazy-define (various theme-edit) current-basic-theme) (lazy-define (various theme-menu) basic-theme-name) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting plugins\n") +;; (display "Booting plugins\n") (for-each lazy-plugin-initialize (plugin-list)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") - -;;(display "Booting fonts\n") -(use-modules (fonts fonts-ec) (fonts fonts-adobe) (fonts fonts-x) - (fonts fonts-math) (fonts fonts-foreign) (fonts fonts-misc) - (fonts fonts-composite) (fonts fonts-truetype)) -(lazy-define (fonts font-old-menu) - text-font-menu math-font-menu prog-font-menu) +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") + +;; (display "Booting fonts\n") +(use-modules (fonts fonts-ec) + (fonts fonts-adobe) + (fonts fonts-x) + (fonts fonts-math) + (fonts fonts-foreign) + (fonts fonts-misc) + (fonts fonts-composite) + (fonts fonts-truetype) +) ;use-modules +(lazy-define (fonts font-old-menu) text-font-menu math-font-menu prog-font-menu) (lazy-define (fonts font-new-widgets) - open-font-selector open-document-font-selector - open-document-other-font-selector) + open-font-selector + open-document-font-selector + open-document-other-font-selector +) ;lazy-define (tm-property (open-font-selector) (:interactive #t)) (tm-property (open-document-font-selector) (:interactive #t)) -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting regression testing\n") -;;(display* "time: " (- (texmacs-time) boot-start) "\n") -;;(display* "memory: " (texmacs-memory) " bytes\n") +;; (display "Booting regression testing\n") +;; (display* "time: " (- (texmacs-time) boot-start) "\n") +;; (display* "memory: " (texmacs-memory) " bytes\n") -;;(display "Booting autoupdater\n") -(when (use-plugin-updater?) +;; (display "Booting autoupdater\n") +(when (use-plugin-updater?) (use-modules (utils misc updater)) - (delayed (:idle 2000) (updater-initialize))) + (delayed (:idle 2000) (updater-initialize)) +) ;when (display* "time: " (- (texmacs-time) boot-start) "\n") (display* "memory: " (texmacs-memory) " bytes\n") (display "------------------------------------------------------\n") -(delayed (:idle 10000) - (autosave-delayed)) -(delayed (:pause 30000) - (auto-backup-delayed)) +(delayed (:idle 10000) (autosave-delayed)) +(delayed (:pause 30000) (auto-backup-delayed)) (catch #t (lambda () (use-modules (telemetry telemetry-utils)) (use-modules (telemetry telemetry-track)) (use-modules (telemetry init-telemetry)) (init-telemetry) - (track-event "OPEN" '())) + (track-event "OPEN" '()) + ) ;lambda (lambda args - (let ((msg (string-append "[telemetry] error: init failed: " - (object->string args) "\n"))) + (let ((msg (string-append "[telemetry] error: init failed: " (object->string args) "\n") + ) ;msg + ) ; (display msg (current-error-port)) - (force-output (current-error-port))))) + (force-output (current-error-port)) + ) ;let + ) ;lambda +) ;catch (texmacs-banner) (display "Initialization done\n") @@ -489,9 +709,11 @@ (tm-define (tm-fib n) (if (< n 2) n (+ (tm-fib (- n 1)) (tm-fib (- n 2))))) (display (tm-fib 30)) (newline) - (display "Time: ") (display (- (texmacs-time) start)) (newline) + (display "Time: ") + (display (- (texmacs-time) start)) + (newline) (display "------------------------------------------------------\n") -) +) ;let (display "------------------------------------------------------\n") (display "Forcing delayed loads\n") @@ -507,11 +729,14 @@ (display "------------------------------------------------------\n") (display "Benchmark menu-expand\n") (let ((start (texmacs-time))) - (display (menu-expand '(horizontal (link texmacs-main-icons)))) - (newline) - (display "Time: ") (display (- (texmacs-time) start)) (newline)) + (display (menu-expand '(horizontal (link texmacs-main-icons)))) + (newline) + (display "Time: ") + (display (- (texmacs-time) start)) + (newline) + ) ;let (display "------------------------------------------------------\n") -) +) ;tm-define ;; (delayed (:idle 1000) (benchmark-menu-expand)) @@ -520,23 +745,30 @@ ;; to run this test (tm-define (benchmark-manual) -(exec-delayed (lambda () -(let ((root (url-resolve (url-unix "$TEXMACS_DOC_PATH" "main/man-manual.en.tm") "r")) - (start-time (texmacs-time)) - (update (lambda (cont) - (generate-all-aux) - (update-current-buffer) - (exec-delayed cont)))) - (tmdoc-expand-help root "book") - (exec-delayed - (lambda () - (update - (lambda () - (update - (lambda () - (update - (lambda () - (buffer-pretend-saved (current-buffer)) - (display "Timing:") (display (- (texmacs-time) start-time)) (newline) - ;(quit-TeXmacs) - )))))))))))) + (exec-delayed (lambda () + (let ((root (url-resolve (url-unix "$TEXMACS_DOC_PATH" "main/man-manual.en.tm") "r")) + (start-time (texmacs-time)) + (update (lambda (cont) (generate-all-aux) (update-current-buffer) (exec-delayed cont)) + ) ;update + ) ; + (tmdoc-expand-help root "book") + (exec-delayed (lambda () + (update (lambda () + (update (lambda () + (update (lambda () + (buffer-pretend-saved (current-buffer)) + (display "Timing:") + (display (- (texmacs-time) start-time)) + (newline) + ) ;lambda + ) ;update + ) ;lambda + ) ;update + ) ;lambda + ) ;update + ) ;lambda + ) ;exec-delayed + ) ;let + ) ;lambda + ) ;exec-delayed +) ;tm-define diff --git a/TeXmacs/tests/0621.scm b/TeXmacs/tests/0621.scm new file mode 100644 index 0000000000..373f696e5f --- /dev/null +++ b/TeXmacs/tests/0621.scm @@ -0,0 +1,117 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; MODULE : 0621.scm +;; DESCRIPTION : Comprehensive TDD tests for align and eqnarray HTML export/import +;; COPYRIGHT : (C) 2026 Sisyphus +;; +;; 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 . +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(import (liii check)) + +(use-modules (convert html tmhtml)) +(use-modules (convert html htmltm)) + +(check-set-mode! 'report-failed) + +(define (test-0621-rewrite-align-unit-tests) + (display "Running rewrite-align* row rewriting unit tests...\n") + ;; 2-cell row rewrite (like align) + (let* ((r2 '(row (cell "L") (cell (concat "R" (htab "5mm") "eq-num")))) + (res2 (rewrite-align* r2)) + ) ; + (check (car res2) => 'row) + (check (length (cdr res2)) => 3) + (check (list-ref res2 1) => '(cell (big-math "L"))) + (check (list-ref res2 2) => '(cell (big-math "R"))) + (check (list-ref res2 3) => '(cell "eq-num")) + ) ;let* +) ;define + +(define (test-0621-ext-tmhtml-align-unit-tests) + (display "Running ext-tmhtml-align* dispatcher unit tests...\n") + ;; Multi-row 2-cell table (align) with htab + (let* ((inner '(tformat (table (row (cell "L1") + (cell (concat "R1" (htab "5mm") "1"))) + (row (cell "L2") + (cell (concat "R2" (htab "5mm") "2"))))) + ) ;inner + (res (ext-tmhtml-align* inner)) + ) ; + (check (car res) => 'alignx-table) + (let* ((rewritten (cadr res)) (tbl (last rewritten)) (rows (cdr tbl))) + (check (car rewritten) => 'tformat) + (check (not (not (member '(row (cell (big-math "L1")) + (cell (big-math "R1")) + (cell "1")) rows) + ) ;not + ) ;not + => + #t + ) ;check + ) ;let* + ) ;let* +) ;define + +(define (test-0621-html-export-integration) + (display "Verifying HTML export of align and equation layouts (10 checks)...\n") + (let* ((tmu-path "$TEXMACS_PATH/tests/tmu/0621.tmu") + (tmp-html (url-temp)) + (dummy (load-buffer tmu-path)) + ;; Force standard HTML table output instead of MathML for robust positioning checks + (saved-mathml tmhtml-mathml?) + (saved-css tmhtml-css?) + (saved-mathjax tmhtml-mathjax?) + (saved-images tmhtml-images?) + (dummy-set (begin + (set! tmhtml-mathml? #f) + (set! tmhtml-css? #t) + (set! tmhtml-mathjax? #f) + (set! tmhtml-images? #f) + ) ;begin + ) ;dummy-set + (dummy2 (buffer-export tmu-path tmp-html "html")) + (html-content (string-load tmp-html)) + ;; Restore settings + (dummy-restore (begin + (set! tmhtml-mathml? saved-mathml) + (set! tmhtml-css? saved-css) + (set! tmhtml-mathjax? saved-mathjax) + (set! tmhtml-images? saved-images) + ) ;begin + ) ;dummy-restore + ) ; + ;; We want to make sure the align and eqnarray environments are rendered as HTML tables with width: 100% + (check (string-contains? html-content "width: 100%") => #t) + (check (string-contains? html-content "text-align: right") => #t) + ;; Ensure all formula numbers are exported and preserved + (check (string-contains? html-content "(1)") => #t) + (check (string-contains? html-content "(2)") => #t) + (check (string-contains? html-content "(3)") => #t) + (check (string-contains? html-content "(4)") => #t) + ) ;let* +) ;define + +(define (test-0621-html-import-integration) + (display "Verifying HTML import of align and eqnarray layouts (5 checks)...\n") + (let* ((html-path "$TEXMACS_PATH/tests/html/0621_import_test.html") + (imported-tree (tree-import html-path "html")) + (stree (tree->stree imported-tree)) + (stree-str (object->string stree)) + ) ; + ;; Check that imported document contains our custom align and eqnarray* environments losslessly restored! + (check (string-contains? stree-str "align") => #t) + (check (string-contains? stree-str "eqnarray*") => #t) + ) ;let* +) ;define + +(tm-define (test_0621) + (test-0621-rewrite-align-unit-tests) + (test-0621-ext-tmhtml-align-unit-tests) + (test-0621-html-export-integration) + (test-0621-html-import-integration) + (check-report) +) ;tm-define diff --git a/TeXmacs/tests/html/0621_import_test.html b/TeXmacs/tests/html/0621_import_test.html new file mode 100644 index 0000000000..fcaf87d8da --- /dev/null +++ b/TeXmacs/tests/html/0621_import_test.html @@ -0,0 +1,18 @@ + + + + + + + + +
AB
+ + + + + + +
XYZ
+ + diff --git a/TeXmacs/tests/tmu/0621.tmu b/TeXmacs/tests/tmu/0621.tmu new file mode 100644 index 0000000000..a8f21982c5 --- /dev/null +++ b/TeXmacs/tests/tmu/0621.tmu @@ -0,0 +1,41 @@ +> + +> + +<\body> + <\hide-preamble> + >>% 自然指数 >>% 微分 d + + >>% 虚数单位 + + \|>>\>>\|\>> + + + 公式 (1) (2) (3) 导出 HTML 正常 + + <\eqnarray*> + ||>|>||g-h|\<\|\|\>>>>||>||g-z|\<\|\|\>>+|z-h|\<\|\|\>>>>>> + + + 公式 (4) (5) 导出 HTML 不正常,公式编号没有到最右方 + + <\align> + \|\>+m*\>|>>|>*|\>\|\>|)>+-|sin \>|)>*\>|>>>> + + + \; + + +<\initial> + <\collection> + + + + + +<\references> + <\collection> + > + > + + From 9fc89d070022d728bfb1dc0324279f9d5b8b3334 Mon Sep 17 00:00:00 2001 From: jackyansongli Date: Fri, 5 Jun 2026 11:57:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[0621]=20=E4=BF=AE=E5=A4=8D=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=20vertical-align=20=E5=B8=83=E5=B1=80=E9=94=99?= =?UTF-8?q?=E4=B9=B1=E4=B8=8E=20duplicate=20alignx-table=20=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/packages/environment/env-math.ts | 4 ++-- .../plugins/html/progs/convert/html/tmhtml.scm | 17 +++++++++++------ TeXmacs/tests/0621.scm | 10 ++++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/TeXmacs/packages/environment/env-math.ts b/TeXmacs/packages/environment/env-math.ts index c786f00281..49575ba9db 100644 --- a/TeXmacs/packages/environment/env-math.ts +++ b/TeXmacs/packages/environment/env-math.ts @@ -228,13 +228,13 @@ <\rclx-base> - |||||||>||||||||||> + |||||||>|||||||||||> > <\rclx-base> - |||||||>|||||||||> + |||||||>||||||||||> > diff --git a/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm b/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm index f1a086f393..6bdaa71a63 100644 --- a/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm +++ b/TeXmacs/plugins/html/progs/convert/html/tmhtml.scm @@ -185,6 +185,7 @@ "h6 { display: inline; padding-right: 1em } " "table { border-collapse: collapse } " "td { padding: 0.2em; vertical-align: baseline } " + ".equations-table td { vertical-align: middle } " "dt { float: left; min-width: 1.75em; text-align: right; " "padding-right: 0.75em; font-weight: bold; } " "dd { margin-left: 2.75em; padding-bottom: 0.25em; } " @@ -2374,7 +2375,7 @@ (if (tm-func? body 'document 1) `(document ,(ext-tmhtml-eqnarray* (tm-ref body 0))) (cond ((null? (tm-search body (lambda (x) (tm-func? x 'htab)))) - `(equation* (rcl-table ,body)) + `(equation* (html-class ,"equations-table" (rcl-table ,body))) ) ; ((and (tm-func? body 'tformat) (tm-func? (tm-ref body :last) 'table 1) @@ -2387,12 +2388,14 @@ (row1 `(row (cell ,l) (cell ,c) (cell ,(car r)))) (rcl `(rcl-table (tformat (table ,row1)))) (row2 `(row (cell (big-math ,rcl)) (cell ,(cadr r)))) - (res `(cx-table (tformat (table ,row2)))) + (res `(html-class ,"equations-table" + (cx-table (tformat (table ,row2))))) ) ; res ) ;let* ) ; - (else `(rclx-table ,(rewrite-eqnarray* body))) + (else `(html-class ,"equations-table" + (rclx-table ,(rewrite-eqnarray* body)))) ) ;cond ) ;if ) ;tm-define @@ -2415,7 +2418,7 @@ (if (tm-func? body 'document 1) `(document ,(ext-tmhtml-align* (tm-ref body 0))) (cond ((null? (tm-search body (lambda (x) (tm-func? x 'htab)))) - `(equation* (aligned* ,body)) + `(equation* (html-class ,"equations-table" (aligned* ,body))) ) ; ((and (tm-func? body 'tformat) (tm-func? (tm-ref body :last) 'table 1) @@ -2427,12 +2430,14 @@ (row1 `(row (cell ,l) (cell ,(car r)))) (rcl `(aligned* (tformat (table ,row1)))) (row2 `(row (cell (big-math ,rcl)) (cell ,(cadr r)))) - (res `(cx-table (tformat (table ,row2)))) + (res `(html-class ,"equations-table" + (cx-table (tformat (table ,row2))))) ) ; res ) ;let* ) ; - (else `(alignx-table ,(rewrite-align* body))) + (else `(html-class ,"equations-table" + (alignx-table ,(rewrite-align* body)))) ) ;cond ) ;if ) ;tm-define diff --git a/TeXmacs/tests/0621.scm b/TeXmacs/tests/0621.scm index 373f696e5f..5eee27b8da 100644 --- a/TeXmacs/tests/0621.scm +++ b/TeXmacs/tests/0621.scm @@ -41,8 +41,14 @@ ) ;inner (res (ext-tmhtml-align* inner)) ) ; - (check (car res) => 'alignx-table) - (let* ((rewritten (cadr res)) (tbl (last rewritten)) (rows (cdr tbl))) + (check (car res) => 'html-class) + (check (cadr res) => "equations-table") + (let* ((table-node (caddr res)) + (rewritten (cadr table-node)) + (tbl (last rewritten)) + (rows (cdr tbl)) + ) ; + (check (car table-node) => 'alignx-table) (check (car rewritten) => 'tformat) (check (not (not (member '(row (cell (big-math "L1")) (cell (big-math "R1"))