| 1 |
% tabularray.4ht (2026-04-22-12:58), generated from tex4ht-4ht.tex |
| 2 |
% Copyright 2022-2026 TeX Users Group |
| 3 |
% |
| 4 |
% This work may be distributed and/or modified under the |
| 5 |
% conditions of the LaTeX Project Public License, either |
| 6 |
% version 1.3c of this license or (at your option) any |
| 7 |
% later version. The latest version of this license is in |
| 8 |
% http://www.latex-project.org/lppl.txt |
| 9 |
% and version 1.3c or later is part of all distributions |
| 10 |
% of LaTeX version 2005/12/01 or later. |
| 11 |
% |
| 12 |
% This work has the LPPL maintenance status "maintained". |
| 13 |
% |
| 14 |
% The Current Maintainer of this work |
| 15 |
% is the TeX4ht Project <http://tug.org/tex4ht>. |
| 16 |
% |
| 17 |
% If you modify this program, changing the |
| 18 |
% version identification would be appreciated. |
| 19 |
\immediate\write-1{version 2026-04-22-12:58} |
| 20 |
|
| 21 |
\NewConfigure{tabularray}{8} |
| 22 |
\NewConfigure{tabularrayignoredcell}{2} |
| 23 |
\NewConfigure{tabularrayattributes}[1]{\concat:config\CellAttributes{#1\space}} |
| 24 |
\NewConfigure{tabularraystyles}[1]{\concat:config\CellStyle{#1}} |
| 25 |
\NewConfigure{tabularraycolumnwidth}{1} |
| 26 |
|
| 27 |
\ExplSyntaxOn |
| 28 |
\NewConfigure{tabularrayhalign}[2]{% |
| 29 |
\cs_set:cpn{tabularray_halign:#1}{#2} |
| 30 |
} |
| 31 |
|
| 32 |
\NewConfigure{tabularrayvalign}[2]{% |
| 33 |
\cs_set:cpn{tabularray_valign:#1}{#2} |
| 34 |
} |
| 35 |
\ExplSyntaxOff |
| 36 |
|
| 37 |
\ExplSyntaxOn |
| 38 |
\long\def\:tempa#1#2#3#4{% |
| 39 |
% insert <table>...</table> |
| 40 |
\a:tabularray\o:__tblr_environ_code:nnnn:{#1}{#2}{#3}{#4}\b:tabularray |
| 41 |
} |
| 42 |
\HLet\__tblr_environ_code:nnnn\:tempa |
| 43 |
|
| 44 |
\long\def\:tempa#1{\int_set:Nn \c@rownum {#1}\xdef\HRow{\@arabic\c@rownum}\c:tabularray\o:__tblr_build_row:N:{#1}\d:tabularray} |
| 45 |
\HLet\__tblr_build_row:N\:tempa |
| 46 |
\ExplSyntaxOff |
| 47 |
|
| 48 |
% disable rules |
| 49 |
\ht:special{t4ht@_} |
| 50 |
\ExplSyntaxOn |
| 51 |
% #1 row number, #2 column, #3 hline number (there can be multiple), #4 css property to be set |
| 52 |
\def\:tblr:hlinestyle#1#2#3#4{ |
| 53 |
% get line height |
| 54 |
\tl_set:Ne \l__tblr_h_tl{ \__tblr_spec_item:ne { hline } { [#1](#3) / @hline-height } } |
| 55 |
% get dash style |
| 56 |
\tl_set:Ne \l__tblr_f_tl{\__tblr_spec_item:ne { hline } { [#1][#2](#3) / @dash }} |
| 57 |
% create CSS only when a dash style is set |
| 58 |
\tl_if_head_eq_meaning:VNT \l__tblr_f_tl \q__tblr_dash { |
| 59 |
% get hline color |
| 60 |
\tl_set:Ne \l__tblr_g_tl { \__tblr_spec_item:ne { hline } { [#1][#2](#3) / fg } } |
| 61 |
\def\:hlinecolor{\#000000} |
| 62 |
% convert color to CSS value if color is set |
| 63 |
\tl_if_empty:NF\l__tblr_g_tl{\get:xcolorcss{\l__tblr_g_tl}\:hlinecolor} |
| 64 |
% \Configure{tabularraystyles} doesn't expand attributes, so we need to expand it here |
| 65 |
% otherwise, we would get wrong color and hline style in the last row, because this macro is called twice here |
| 66 |
\tl_set:Ne \l__tblr_f_tl { \tl_tail:N \l__tblr_f_tl } |
| 67 |
\cs_set:ce{#4:}{#4:\dim_to_decimal_in_unit:nn{\l__tblr_h_tl*2}{1px}px~\l__tblr_f_tl\space~\:hlinecolor;} |
| 68 |
\Configure{tabularraystyles}{\csname#4:\endcsname} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
\def\:tblr:vlinestyle#1#2#3#4{ |
| 73 |
\tl_set:Ne \l__tblr_t_tl{ \__tblr_spec_item:ne { vline } { [#2](#3) / @vline-width } } |
| 74 |
\tl_set:Ne \l__tblr_f_tl{\__tblr_spec_item:ne { vline } { [#1][#2](#3) / @dash }} |
| 75 |
\tl_if_head_eq_meaning:VNT \l__tblr_f_tl \q__tblr_dash { |
| 76 |
\tl_set:Ne \l__tblr_g_tl { \__tblr_spec_item:ne { vline } { [#1][#2](#3) / fg } } |
| 77 |
\def\:hlinecolor{\#000000} |
| 78 |
% convert color to CSS value if color is set |
| 79 |
\tl_if_empty:NF\l__tblr_g_tl{\get:xcolorcss{\l__tblr_g_tl}\:hlinecolor} |
| 80 |
% \Configure{tabularraystyles} doesn't expand attributes, so we need to expand it here |
| 81 |
% otherwise, we would get wrong color and hline style in the last row, because this macro is called twice here |
| 82 |
\tl_set:Ne \l__tblr_f_tl { \tl_tail:N \l__tblr_f_tl } |
| 83 |
\cs_set:ce{#4:}{#4:\dim_to_decimal_in_unit:nn{\l__tblr_t_tl*2}{1px}px~\l__tblr_f_tl\space~\:hlinecolor;} |
| 84 |
\Configure{tabularraystyles}{\csname#4:\endcsname} |
| 85 |
} |
| 86 |
} |
| 87 |
\ExplSyntaxOff |
| 88 |
|
| 89 |
\ExplSyntaxOn |
| 90 |
\long\def\:tempa#1#2{% |
| 91 |
% find columns that are covered by rowspan and colspan |
| 92 |
\xdef\HCol{\@arabic\c@colnum} |
| 93 |
\xdef\HRow{\@arabic\c@rownum} |
| 94 |
\xdef\HMultispan{\int_use:N \lTblrCellColSpanInt} |
| 95 |
\xdef\HRowspan{\int_use:N \lTblrCellRowSpanInt} |
| 96 |
\let\CellAttributes\@empty |
| 97 |
\let\CellStyle\@empty |
| 98 |
% calculate ignored cells, if the current cell uses colspan or rowspan |
| 99 |
\int_step_inline:nnn{\c@rownum }{\c@rownum - 1 + \lTblrCellRowSpanInt}{ |
| 100 |
\int_step_inline:nnn{\c@colnum }{\c@colnum - 1 + \lTblrCellColSpanInt}{ |
| 101 |
% the loop always matches the current cell, we must ignore it |
| 102 |
\str_if_eq:eeF{\HCol.\HRow}{####1.##1}{% |
| 103 |
\cs_gset:cpn{ignoredcell-####1-##1}{} |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
\cs_if_exist_use:c{tabularray_halign:\g__tblr_cell_halign_tl} |
| 108 |
\cs_if_exist_use:c{tabularray_valign:\g__tblr_cell_valign_tl} |
| 109 |
% the vertical aligment can be set also in \g__tblr_cell_middle_tl, so we should try it as well |
| 110 |
\cs_if_exist_use:c{tabularray_valign:\g__tblr_cell_middle_tl} |
| 111 |
% calculate column width |
| 112 |
\dim_compare:nNnT {\__tblr_data_item:nen{column}{\HCol}{@col-width}} > {0pt}{ |
| 113 |
\__tblr_get_table_width:% initialize \tablewidth |
| 114 |
\edef\HColWidth{\fp_eval:n{\__tblr_data_item:nen{column}{\HCol}{@col-width}/\tablewidth*100}\%} |
| 115 |
% save table width, preferably in CSS |
| 116 |
\a:tabularraycolumnwidth% |
| 117 |
} |
| 118 |
% there can be multiple hlines for each cell, but we only suport the first one, because of limitations of CSS |
| 119 |
\:tblr:hlinestyle{#1}{#2}{1}{border-top} |
| 120 |
\int_compare:nNnT{\HRow + \HRowspan - 1} = {\c@rowcount}{% |
| 121 |
% draw hline below the last row |
| 122 |
\:tblr:hlinestyle{\int_eval:n{\c@rownum + 1}}{#2}{1}{border-bottom} |
| 123 |
} |
| 124 |
% the same is true for vlines |
| 125 |
\:tblr:vlinestyle{#1}{#2}{1}{border-left} |
| 126 |
\int_compare:nNnT{\HCol + \HMultispan - 1} = {\c@colcount}{% |
| 127 |
% draw hline below the last row |
| 128 |
\:tblr:vlinestyle{#1}{\int_eval:n{\c@colnum + 1}}{1}{border-right} |
| 129 |
} |
| 130 |
% support for the background color |
| 131 |
\tl_set:Ne \l__tblr_b_tl |
| 132 |
{ \__tblr_data_item:neen { cell } {#1} {#2} { background } } |
| 133 |
% save background color to the list of CSS, if it is set |
| 134 |
\tl_if_empty:NF \l__tblr_b_tl{ |
| 135 |
\get:xcolorcss{\l__tblr_b_tl}\:bgcolor |
| 136 |
\Configure{tabularraystyles}{background-color: \:bgcolor;} |
| 137 |
} |
| 138 |
\tl_set:Ne \l__tblr_cell_fg_tl |
| 139 |
{ \__tblr_data_item:neen { cell } {#1} {#2} { foreground } } |
| 140 |
% save background color to the list of CSS, if it is set |
| 141 |
\tl_if_empty:NF \l__tblr_cell_fg_tl{ |
| 142 |
\get:xcolorcss{\l__tblr_cell_fg_tl}\:fgcolor |
| 143 |
\Configure{tabularraystyles}{color:\:fgcolor;} |
| 144 |
} |
| 145 |
% We can use something like \Configure{tabularrayattributes}{rowspan="\HRowspan"} in \Configure{tabularray} |
| 146 |
% to declare correct attributes for joined cells |
| 147 |
\int_compare:nNnT {\HRowspan} > {1}{\g:tabularray} |
| 148 |
\int_compare:nNnT {\HMultispan} > {1}{\h:tabularray} |
| 149 |
\cs_if_exist:cTF{ignoredcell-\the\c@colnum-\the\c@rownum}{% |
| 150 |
\a:tabularrayignoredcell\e:tabularray\o:__tblr_build_cell_content:NN:{#1}{#2}\f:tabularray\b:tabularrayignoredcell |
| 151 |
}{% |
| 152 |
\e:tabularray\o:__tblr_build_cell_content:NN:{#1}{#2}\f:tabularray |
| 153 |
} |
| 154 |
% the ignored cell is global, so we must undefine it after the thes |
| 155 |
\cs_undefine:c{ignoredcell-\the\c@colnum-\the\c@rownum}% |
| 156 |
} |
| 157 |
\HLet\__tblr_build_cell_content:NN\:tempa |
| 158 |
|
| 159 |
\ExplSyntaxOff |
| 160 |
|
| 161 |
\ExplSyntaxOn |
| 162 |
\HLet\__tblr_get_vcenter_box:N\:gobble |
| 163 |
\ExplSyntaxOff |
| 164 |
|
| 165 |
\ExplSyntaxOn |
| 166 |
\def\:tempa{ |
| 167 |
% \__tblr_build_row_head_foot: <- we don't use this, because it moves table header to the foot |
| 168 |
\__tblr_build_table_head_foot:} |
| 169 |
\HLet\__tblr_build_head_foot:\:tempa |
| 170 |
% this is a copy of the original tabularray command, because it produced an error when I tried to modify it using \HLet |
| 171 |
\cs_set_protected:Npn \__tblr_build_table_label_entry: |
| 172 |
{ |
| 173 |
\bool_if:NF \l__tblr_table_no_label_bool |
| 174 |
{\a:tabularraycaption% |
| 175 |
\refstepcounter { table } |
| 176 |
\tl_if_empty:NF \lTblrLabelTl |
| 177 |
{ |
| 178 |
\clist_map_inline:Nn \lTblrRefMoreClist |
| 179 |
{ \ExpTblrTemplate { caption-ref } { ##1 } } |
| 180 |
\exp_args:NV \label \lTblrLabelTl |
| 181 |
} |
| 182 |
} |
| 183 |
%% We put caption-lot code at last, so that a user can modify \lTblrEntryTl |
| 184 |
%% in a caption-label template. For example, a user may want to use |
| 185 |
%% short caption in nameref, but at the same time not to add LoT entry. |
| 186 |
\bool_if:NF \l__tblr_table_no_entry_bool |
| 187 |
{ \UseTblrTemplate { caption-lot } { default } } |
| 188 |
} |
| 189 |
|
| 190 |
\DeclareTblrTemplate { caption-text } { tex4ht } { \InsertTblrText { caption }\b:tabularraycaption } |
| 191 |
\SetTblrTemplate { caption-text } { tex4ht } |
| 192 |
|
| 193 |
% prevent extra paragraph before caption |
| 194 |
\pend:defI\__tblr_build_long_table:n{\IgnorePar} |
| 195 |
|
| 196 |
\NewConfigure{tabularraycaption}{2} |
| 197 |
|
| 198 |
\ExplSyntaxOff |
| 199 |
|
| 200 |
\Hinput{tabularray} |
| 201 |
\endinput |
| 202 |
|