Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion TeXmacs/packages/environment/env-math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,20 @@

<assign|rclx-table|<\macro|body>
<\rclx-base>
<tformat|<twith|table-width|1par>|<twith|table-min-cols|4>|<twith|table-max-cols|4>|<cwith|1|-1|1|1|cell-lsep|0spc>|<cwith|1|-1|-1|-1|cell-rsep|0spc>|<cwith|1|-1|1|-1|cell-bsep|0sep>|<cwith|1|-1|1|-1|cell-tsep|0sep>|<cwith|1|-2|1|-1|cell-bsep|<eqn-row-sep>>|<cwith|1|-1|1|1|cell-hpart|1>|<cwith|1|-1|-2|-2|cell-hpart|2>|<cwith|1|-1|1|1|cell-halign|r>|<cwith|1|-1|1|1|cell-hyphen|b>|<cwith|1|-1|2|-2|cell-halign|c>|<cwith|1|-1|-2|-2|cell-halign|l>|<cwith|1|-1|-2|-2|cell-hyphen|t>|<cwith|1|-1|-1|-1|cell-halign|r>|<cwith|1|-1|1|-1|cell-block|no>|<arg|body>>
<tformat|<twith|table-width|1par>|<twith|table-min-cols|4>|<twith|table-max-cols|4>|<cwith|1|-1|1|1|cell-lsep|0spc>|<cwith|1|-1|-1|-1|cell-rsep|0spc>|<cwith|1|-1|1|-1|cell-bsep|0sep>|<cwith|1|-1|1|-1|cell-tsep|0sep>|<cwith|1|-2|1|-1|cell-bsep|<eqn-row-sep>>|<cwith|1|-1|1|1|cell-hpart|1>|<cwith|1|-1|-2|-2|cell-hpart|2>|<cwith|1|-1|1|1|cell-halign|r>|<cwith|1|-1|1|1|cell-hyphen|b>|<cwith|1|-1|2|-2|cell-halign|c>|<cwith|1|-1|-2|-2|cell-halign|l>|<cwith|1|-1|-2|-2|cell-hyphen|t>|<cwith|1|-1|-1|-1|cell-halign|r>|<cwith|1|-1|1|-1|cell-block|no>|<cwith|1|-1|1|-1|cell-valign|c>|<arg|body>>
</rclx-base>
</macro>>

<assign|alignx-table|<\macro|body>
<\rclx-base>
<tformat|<twith|table-width|1par>|<twith|table-min-cols|3>|<twith|table-max-cols|3>|<cwith|1|-1|1|1|cell-lsep|0spc>|<cwith|1|-1|-1|-1|cell-rsep|0spc>|<cwith|1|-1|1|-1|cell-bsep|0sep>|<cwith|1|-1|1|-1|cell-tsep|0sep>|<cwith|1|-2|1|-1|cell-bsep|<eqn-row-sep>>|<cwith|1|-1|1|1|cell-hpart|1>|<cwith|1|-1|2|2|cell-hpart|1>|<cwith|1|-1|1|1|cell-halign|r>|<cwith|1|-1|1|1|cell-hyphen|b>|<cwith|1|-1|2|2|cell-halign|l>|<cwith|1|-1|2|2|cell-hyphen|t>|<cwith|1|-1|-1|-1|cell-halign|r>|<cwith|1|-1|1|-1|cell-block|no>|<cwith|1|-1|1|-1|cell-valign|c>|<arg|body>>
</rclx-base>
</macro>>

<assign|tmhtml-eqnarray*|<macro|body|<extern|ext-tmhtml-eqnarray*|<arg|body>>>>

<assign|tmhtml-align*|<macro|body|<extern|ext-tmhtml-align*|<arg|body>>>>

\;
</body>

Expand Down
34 changes: 25 additions & 9 deletions TeXmacs/plugins/html/progs/convert/html/htmltm.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
59 changes: 52 additions & 7 deletions TeXmacs/plugins/html/progs/convert/html/tmhtml.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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; } "
Expand Down Expand Up @@ -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)
Expand All @@ -2387,12 +2388,56 @@
(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

(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* (html-class ,"equations-table" (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 `(html-class ,"equations-table"
(cx-table (tformat (table ,row2)))))
) ;
res
) ;let*
) ;
(else `(html-class ,"equations-table"
(alignx-table ,(rewrite-align* body))))
) ;cond
) ;if
) ;tm-define
Expand Down
Loading
Loading