| 1 |
% \iffalse meta-comment |
| 2 |
% vim: tw=80 spl=en |
| 3 |
% |
| 4 |
%% File: cellprops.dtx (C) Copyright 2016-2021 RIVAUD Julien |
| 5 |
%% |
| 6 |
%% It may be distributed and/or modified under the conditions of the |
| 7 |
%% General Public License (GPL), either version 3 of this |
| 8 |
%% license or (at your option) any later version. |
| 9 |
% |
| 10 |
%<*driver|package> |
| 11 |
% The version of expl3 required is tested as early as possible, as |
| 12 |
% some really old versions do not define \ProvidesExplPackage. |
| 13 |
\NeedsTeXFormat{LaTeX2e}[1995/12/01] |
| 14 |
\RequirePackage{expl3}[2018/06/19] |
| 15 |
\def\ExplFileName{cellprops} |
| 16 |
\def\ExplFileDescription{CSS-like cell and table properties} |
| 17 |
\def\ExplFileDate{2021/01/30} |
| 18 |
\def\ExplFileVersion{2.0} |
| 19 |
%</driver|package> |
| 20 |
%<*driver> |
| 21 |
\documentclass[full]{l3doc} |
| 22 |
\usepackage[english]{babel} |
| 23 |
\usepackage{longtable} |
| 24 |
\usepackage{cellprops} |
| 25 |
\begin{document} |
| 26 |
\DocInput{\jobname.dtx} |
| 27 |
\end{document} |
| 28 |
%</driver> |
| 29 |
% \fi |
| 30 |
% |
| 31 |
% \title{^^A |
| 32 |
% The \textsf{\ExplFileName} package\\ \ExplFileDescription^^A |
| 33 |
% \thanks{This file describes v\ExplFileVersion, |
| 34 |
% last revised \ExplFileDate.}^^A |
| 35 |
% } |
| 36 |
% |
| 37 |
% \author{^^A |
| 38 |
% Julien ``\_FrnchFrgg\_'' \textsc{Rivaud}\thanks |
| 39 |
% {^^A |
| 40 |
% E-mail: |
| 41 |
% \href{mailto:[email protected]} |
| 42 |
% {[email protected]}^^A |
| 43 |
% }^^A |
| 44 |
% } |
| 45 |
% |
| 46 |
% \date{Released \ExplFileDate} |
| 47 |
% |
| 48 |
% \maketitle |
| 49 |
% |
| 50 |
% \begin{documentation} |
| 51 |
% |
| 52 |
% |
| 53 |
% |
| 54 |
% \section{\pkg{\ExplFileName} documentation} |
| 55 |
% |
| 56 |
% This package reworks the internals of \env{tabular}, \env{array}, and similar |
| 57 |
% constructs, and adds a \cs{cellprops} command accepting CSS-like selectors and |
| 58 |
% properties. It implements the "border-collapse: separate" CSS model. |
| 59 |
% |
| 60 |
% It depends on \pkg{mdwtab}, \pkg{xcolor} and of course \pkg{expl3} and |
| 61 |
% \pkg{xparse}. |
| 62 |
% |
| 63 |
% \pkg{cellprops} default settings mimick the LaTeX layout, that is left and |
| 64 |
% right padding equal to "\tabcolsep" or "\arraycolsep", zero top and bottom |
| 65 |
% padding, but minimum height and depth corresponding to the table strut box. |
| 66 |
% |
| 67 |
% I recommend to add globally: |
| 68 |
%\begin{verbatim} |
| 69 |
% \cellprops{ td { padding: 1ex; min-height: 0pt; min-depth: 0pt; } } |
| 70 |
%\end{verbatim} |
| 71 |
% so that you get better-looking tables by default. |
| 72 |
% |
| 73 |
% \subsection{Examples} |
| 74 |
% |
| 75 |
% To produce the (arguably ugly): |
| 76 |
% \[ |
| 77 |
% \cellprops{ |
| 78 |
% td { |
| 79 |
% padding: 1ex; |
| 80 |
% min-height: 0pt; |
| 81 |
% min-depth: 0pt; |
| 82 |
% border-style: none solid solid none; |
| 83 |
% text-align: center; |
| 84 |
% } |
| 85 |
% table { |
| 86 |
% background-color: black!5!white; |
| 87 |
% } |
| 88 |
% tr:nth-child(even) { |
| 89 |
% background-color: black!15!white; |
| 90 |
% } |
| 91 |
% td:nth-child(even) { |
| 92 |
% background-color: yellow!20!white |
| 93 |
% } |
| 94 |
% tr:nth-child(even) td:nth-child(even) { |
| 95 |
% background-color: yellow!50!white; |
| 96 |
% } |
| 97 |
% tr:first-child td { |
| 98 |
% border-top-style: solid; |
| 99 |
% } |
| 100 |
% td:first-child { |
| 101 |
% border-left-style: solid; |
| 102 |
% math-mode: text; |
| 103 |
% text-align: left; |
| 104 |
% } |
| 105 |
% tr:nth-child(6) td:nth-child(1) { |
| 106 |
% vertical-align: top; % see remark in usage guide |
| 107 |
% } |
| 108 |
% tr:nth-child(6) td:nth-child(2) { |
| 109 |
% vertical-align: middle; |
| 110 |
% } |
| 111 |
% tr:nth-child(6) td:nth-child(3) { |
| 112 |
% vertical-align: bottom; % see remark in usage guide |
| 113 |
% } |
| 114 |
% } |
| 115 |
% \begin{array}{nnnp{5em}} |
| 116 |
% This is text & A_2 & A_3 & A_4 \\ |
| 117 |
% B1 & This is maths & B_3 & \\ |
| 118 |
% C1 & C_2 & X & Y \\ |
| 119 |
% D1 & D_2 & DX & v \\ |
| 120 |
% & F & \int_a^b f(t) dt & v \\ |
| 121 |
% \fbox{Top} & \fbox{Middle} & \fbox{Bottom} & \fbox{Baseline}% |
| 122 |
% \textcolor{red}{% |
| 123 |
% \kern -9cm\relax |
| 124 |
% \vrule height 0.1pt depth 0.1pt width 10cm |
| 125 |
% \kern -1cm\relax |
| 126 |
% }\textcolor{blue}{% |
| 127 |
% \kern -9cm\relax |
| 128 |
% \vrule height 0.52ex depth -0.48ex width 10cm |
| 129 |
% \kern -1cm\relax |
| 130 |
% } \\ |
| 131 |
% \end{array} |
| 132 |
% \] |
| 133 |
% you can use: |
| 134 |
%\begin{verbatim} |
| 135 |
% \[ |
| 136 |
% \cellprops{ |
| 137 |
% td { |
| 138 |
% padding: 1ex; |
| 139 |
% min-height: 0pt; |
| 140 |
% min-depth: 0pt; |
| 141 |
% border-style: none solid solid none; |
| 142 |
% text-align: center; |
| 143 |
% } |
| 144 |
% table { |
| 145 |
% background-color: black!5!white; |
| 146 |
% } |
| 147 |
% tr:nth-child(even) { |
| 148 |
% background-color: black!15!white; |
| 149 |
% } |
| 150 |
% td:nth-child(even) { |
| 151 |
% background-color: yellow!20!white |
| 152 |
% } |
| 153 |
% tr:nth-child(even) td:nth-child(even) { |
| 154 |
% background-color: yellow!50!white; |
| 155 |
% } |
| 156 |
% tr:first-child td { |
| 157 |
% border-top-style: solid; |
| 158 |
% } |
| 159 |
% td:first-child { |
| 160 |
% border-left-style: solid; |
| 161 |
% math-mode: text; |
| 162 |
% text-align: left; |
| 163 |
% } |
| 164 |
% tr:nth-child(6) td:nth-child(1) { |
| 165 |
% vertical-align: top; % see remark in usage guide |
| 166 |
% } |
| 167 |
% tr:nth-child(6) td:nth-child(2) { |
| 168 |
% vertical-align: middle; |
| 169 |
% } |
| 170 |
% tr:nth-child(6) td:nth-child(3) { |
| 171 |
% vertical-align: bottom; % see remark in usage guide |
| 172 |
% } |
| 173 |
% } |
| 174 |
% \begin{array}{nnnp{5em}} |
| 175 |
% This is text & A_2 & A_3 & A_4 \\ |
| 176 |
% B1 & This is maths & B_3 & \\ |
| 177 |
% C1 & C_2 & X & Y \\ |
| 178 |
% D1 & D_2 & DX & v \\ |
| 179 |
% & F & \int_a^b f(t) dt & v \\ |
| 180 |
% \fbox{Top} & \fbox{Middle} & \fbox{Bottom} & \fbox{Baseline}% |
| 181 |
% \textcolor{red}{% |
| 182 |
% \kern -9cm\relax |
| 183 |
% \vrule height 0.1pt depth 0.1pt width 10cm |
| 184 |
% \kern -1cm\relax |
| 185 |
% }\textcolor{blue}{% |
| 186 |
% \kern -9cm\relax |
| 187 |
% \vrule height 0.52ex depth -0.48ex width 10cm |
| 188 |
% \kern -1cm\relax |
| 189 |
% } \\ |
| 190 |
% \end{array} |
| 191 |
% \] |
| 192 |
%\end{verbatim} |
| 193 |
% |
| 194 |
% You can also use the \env{longtable} environment: |
| 195 |
% |
| 196 |
%\begingroup |
| 197 |
% |
| 198 |
%\cellprops{ |
| 199 |
% td { border: thin solid black; } |
| 200 |
% tr:nth-child(-n+3) { background-color: black!10; } |
| 201 |
% tr:nth-child(n+8) { background-color: blue!10; } |
| 202 |
% tr:nth-child(4n) td:first-child, |
| 203 |
% tr:nth-child(4n+1) td:nth-child(2), |
| 204 |
% tr:nth-child(4n+2) td:nth-child(3), |
| 205 |
% tr:nth-child(4n+3) td:nth-child(4) { |
| 206 |
% border: thick solid red; |
| 207 |
% } |
| 208 |
%} |
| 209 |
%\begin{longtable}{nnnn} |
| 210 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 211 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 212 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 213 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 214 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 215 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 216 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 217 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 218 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 219 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 220 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 221 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 222 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 223 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 224 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 225 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 226 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 227 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 228 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 229 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 230 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 231 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 232 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 233 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 234 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 235 |
%\end{longtable} |
| 236 |
% |
| 237 |
%\endgroup |
| 238 |
% |
| 239 |
% This table has been produced by: |
| 240 |
%\begin{verbatim} |
| 241 |
% \cellprops{ |
| 242 |
% td { border: thin solid black; } |
| 243 |
% tr:nth-child(-n+3) { background-color: black!10; } |
| 244 |
% tr:nth-child(n+8) { background-color: blue!10; } |
| 245 |
% tr:nth-child(4n) td:first-child, |
| 246 |
% tr:nth-child(4n+1) td:nth-child(2), |
| 247 |
% tr:nth-child(4n+2) td:nth-child(3), |
| 248 |
% tr:nth-child(4n+3) td:nth-child(4) { |
| 249 |
% border: thick solid red; |
| 250 |
% } |
| 251 |
% } |
| 252 |
% \begin{longtable}{nnnn} |
| 253 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 254 |
% ... |
| 255 |
% aaaaa & baaaa & caaaaa & dbbbb \\ |
| 256 |
% \end{longtable} |
| 257 |
%\end{verbatim} |
| 258 |
% |
| 259 |
% \subsection{Usage guide} |
| 260 |
% |
| 261 |
% \def\OR{\string| } |
| 262 |
% |
| 263 |
% \def\bracket#1{\<#1>:} |
| 264 |
% \def\<#1>{{\normalfont<\textsl{#1}>}} |
| 265 |
% \begin{description}[format=\bracket, |
| 266 |
% wide,leftmargin=9em,labelwidth=!,labelsep=0pt, |
| 267 |
% ] |
| 268 |
% \item[usage] "'\cellprops{'" [ \<selectors> "'{'" \<properties> "'}'" ]* "'}'" |
| 269 |
% \item[selectors] \<selector> ["," \<selectors> ] |
| 270 |
% \item[selector] [\<table> "' '"] [\<tr> "' '"] [\<td> "' '"] [\<parbox>] |
| 271 |
% \item[table] "'table'" ["'.'" \<class>]* ["':where(.'"\<class>"')'"]* |
| 272 |
% \OR "':where('"\<table>"')'" |
| 273 |
% \item[tr] "'tr'" [\<pseudoclass>]* \OR "':where('"\<tr>"')'" |
| 274 |
% \item[td] "'td'" [\<pseudoclass>]* \OR "':where('"\<td>"')'" |
| 275 |
% \item[parbox] "'p'" \OR "':where('"\<p>"')'" |
| 276 |
% \item[pseudoclass] "':where('"[\<pseudoclass>]*"')'" \OR "':nth-child('"\<nth>"')" |
| 277 |
% \item[nth] |
| 278 |
% "'odd'" \OR "'even'" \OR \<number> \OR |
| 279 |
% \<number>"'n+'"\<number> \OR \<number>"'n-'"\<number> |
| 280 |
% \item[properties] [ \<property> "';'" ]* |
| 281 |
% \item[property] |
| 282 |
% "'padding: '" ( \<dimension> ) \{1,4\} \OR \\ |
| 283 |
% "'padding-top: '" \<dimension> \OR \\ |
| 284 |
% "'padding-right: '" \<dimension> \OR \\ |
| 285 |
% "'padding-bottom: '" \<dimension> \OR \\ |
| 286 |
% "'padding-left: '" \<dimension> \OR \\ |
| 287 |
% "'min-height: '" \<dimension> \OR \\ |
| 288 |
% "'min-depth: '" \<dimension> \OR \\ |
| 289 |
% "'min-width: '" \<dimension> \OR \\ |
| 290 |
% "'text-align: '" ( "'left'" \OR "'right'" \OR "'center'" ) \OR \\ |
| 291 |
% "'vertical-align: '" ( "'top'" \OR "'middle'" \OR "'baseline'" \OR "'bottom'" ) \OR \\ |
| 292 |
% "'math-mode: '" ( "'text'" \OR "'math'" \OR "'auto'" ) \OR \\ |
| 293 |
% "'color: '" \<color> \OR \\ |
| 294 |
% "'background-color: '" ( \<color> \OR "'transparent'" ) \OR \\ |
| 295 |
% "'border: '" [ \<bd-width> ] [ \<bd-style> ] [ \<color> ] \OR \\ |
| 296 |
% "'border-top: '" [ \<bd-width> ] [ \<bd-style> ] [ \<color> ] \OR \\ |
| 297 |
% "'border-right: '" [ \<bd-width> ] [ \<bd-style> ] [ \<color> ] \OR \\ |
| 298 |
% "'border-bottom: '" [ \<bd-width> ] [ \<bd-style> ] [ \<color> ] \OR \\ |
| 299 |
% "'border-left: '" [ \<bd-width> ] [ \<bd-style> ] [ \<color> ] \OR \\ |
| 300 |
% "'border-width: '" ( \<bd-width> ) \{1,4\} \OR \\ |
| 301 |
% "'border-top-width: '" \<bd-width> ) \OR \\ |
| 302 |
% "'border-right-width: '" \<bd-width> ) \OR \\ |
| 303 |
% "'border-bottom-width: '" \<bd-width> ) \OR \\ |
| 304 |
% "'border-left-width: '" \<bd-width> ) \OR \\ |
| 305 |
% "'border-style: '" ( \<bd-style> ) \{1,4\} \OR \\ |
| 306 |
% "'border-top-style: '" \<bd-style> ) \OR \\ |
| 307 |
% "'border-right-style: '" \<bd-style> ) \OR \\ |
| 308 |
% "'border-bottom-style: '" \<bd-style> ) \OR \\ |
| 309 |
% "'border-left-style: '" \<bd-style> ) \OR \\ |
| 310 |
% "'border-color: '" ( \<color> ) \{1,4\} \OR \\ |
| 311 |
% "'border-top-color: '" \<color> ) \OR \\ |
| 312 |
% "'border-right-color: '" \<color> ) \OR \\ |
| 313 |
% "'border-bottom-color: '" \<color> ) \OR \\ |
| 314 |
% "'border-left-color: '" \<color> ) |
| 315 |
% \item[color] "'inherit'" \OR \<xcolor-expression> \OR \\ |
| 316 |
% "'rgb('"\<red-0-255>"','"\<green-0-255>"','"\<blue-0-255>"')'" \OR \\ |
| 317 |
% "'hsl('"\<hue-0-360>"','"\<sat-0-1>"','"\<lum-0-1>"')'" |
| 318 |
% \end{description} |
| 319 |
% |
| 320 |
% Most of these properties are straight-forward. You should check a |
| 321 |
% CSS documentation to get more information. A very good source is the Mozilla |
| 322 |
% Developer Network. |
| 323 |
% |
| 324 |
% Here are the supported column types: |
| 325 |
% \begin{itemize} |
| 326 |
% \item "n": The most basic cell type, hbox, honoring all properties. |
| 327 |
% \item "l", "c" and "r": Same as "n" but with forced "text-align". |
| 328 |
% \item "Ml", "Mc" and "Mr": Same as column "l", "c" and "r" but enforces |
| 329 |
% "math-mode: math". The net effect is that "Mc" will create a centered |
| 330 |
% column whose contents are in non-display math mode. |
| 331 |
% \item "T"\<align>: Same as "M"\<align> but enforces "math-mode: text". |
| 332 |
% \item "p{"\<width>"}", "m"\<width> and "b"\<width>: parbox cell with the |
| 333 |
% corresponding vertical alignment (\cs{vtop}, \cs{vcenter} or \cs{vbox}). |
| 334 |
% \item "*{"\<count>"}{"\<coltypes>"}": same as in \pkg{array} or |
| 335 |
% \pkg{mdwtab}. |
| 336 |
% \item ">{"\<prefix>"}" and "<{"\<suffix>"}": |
| 337 |
% same as in \pkg{array} or \pkg{mdwtab}. |
| 338 |
% \item You can try to use constructs of \pkg{array} or \pkg{mdwtab}, but they |
| 339 |
% might alter the function of \pkg{cellprops}. Most should be fine though. |
| 340 |
% \end{itemize} |
| 341 |
% The intended usage is to use "n"-type columns and set the properties with CSS, |
| 342 |
% but \LaTeX-like columns in the preamble are often less verbose. |
| 343 |
% |
| 344 |
% Details for some properties: |
| 345 |
% |
| 346 |
% \begin{itemize} |
| 347 |
% \item "math-mode: auto" means that the cell will be in math mode in |
| 348 |
% environments \env{array}, \env{matrix}, \dots, and in text mode in |
| 349 |
% environments like \env{tabular}, \dots |
| 350 |
% \item "background-color" is only painted on the cell, and "transparent" |
| 351 |
% actually means "inherit" except that if all values encountered are |
| 352 |
% "inherit"/"transparent" no background is painted at all. That means that |
| 353 |
% (currently) you cannot paint a row in some color and rely on |
| 354 |
% transparency to have it bleed through a cell background. |
| 355 |
% \item There are no columns in the CSS object model so you have to use |
| 356 |
% "td:nth-child()" to select a column. Currently, cells spanning several |
| 357 |
% columns actually increase the child count by the number of column they |
| 358 |
% span, so that nth-child can still be used to select columns. |
| 359 |
% This is not consistent with the HTML specification of tables, but acts |
| 360 |
% as if a cell spanning multiple columns was implicitly creating |
| 361 |
% "display: none" empty cell siblings following it. |
| 362 |
% \item Any ":nth-child("$A$"n+"$B$")" or ":nth-child("$A$"n)" or |
| 363 |
% ":nth-child("$B$")" is supported, with arbitrary $A$~and~$B$, including |
| 364 |
% nothing for~$A$ (standing for~$A = 1$) or just a minus sign (standing |
| 365 |
% for~$A = -1$). |
| 366 |
% \item "vertical-align" values "baseline" and "middle" are following the CSS |
| 367 |
% specification. On the other hand, "top" (resp.~"bottom") align the top |
| 368 |
% (resp.~bottom) of the cell with the row baseline which gives a |
| 369 |
% different result than CSS if there is mixed alignment in the row. |
| 370 |
% The common case where all cells have "vertical-align: top" or |
| 371 |
% "vertical-align: bottom" behaves as expected from the CSS |
| 372 |
% specification. |
| 373 |
% |
| 374 |
% As fas as I can tell, obeying CSS in all cases would require |
| 375 |
% typesetting each row in two passes. |
| 376 |
% \item Class names are matched against the classes defined with |
| 377 |
% \cs{cellpropsclass}, which takes a space-separated list of classes. By |
| 378 |
% default, \cs{cellpropsclass} also add as a class the name of the |
| 379 |
% environment that created the tabular-like structure (that is, "tabular" |
| 380 |
% or "array" or "matrix" or similar). If you do not want that behavior, |
| 381 |
% you can use \cs{cellpropsclass*}. The class list is |
| 382 |
% redefined locally, and \pkg{cellprops} initially calls |
| 383 |
% "\cellpropsclass{}". |
| 384 |
% \item The ":where()" pseudo-class is the same as in CSS selectors level 4, |
| 385 |
% except that it does not accept spaces nor commas. Its only effect is to |
| 386 |
% neutering the specificity of the selectors within while still keeping |
| 387 |
% their matching conditions. This is mainly useful to write default yet |
| 388 |
% specific rules whose specificity would otherwise dwarf simple rules. |
| 389 |
% \end{itemize} |
| 390 |
% |
| 391 |
% \subsection{Compatibility} |
| 392 |
% |
| 393 |
% This package has been tested compatible with \pkg{diagbox}, \pkg{spreadtab}, |
| 394 |
% \pkg{collcell}. Compatibility with \pkg{longtable} has been specifically taken |
| 395 |
% care of, provided \pkg{cellprops} is loaded afterwards. Table packages that |
| 396 |
% only introduce new column types should be loaded after \pkg{mdwtab}, so either |
| 397 |
% you load \pkg{mdwtab} manually and load your package in between \pkg{mdwtab} |
| 398 |
% and \pkg{cellprops}, or you load your package after \pkg{cellprops} (provided |
| 399 |
% it doesn't overwrite the machinery). |
| 400 |
% |
| 401 |
% \subsection{TODO} |
| 402 |
% |
| 403 |
% Add a test suite with compatibility tests. Improve |
| 404 |
% the documentation, and test more \LaTeX\ table constructs and preamble column |
| 405 |
% types. |
| 406 |
% |
| 407 |
% \end{documentation} |
| 408 |
% |
| 409 |
% \begin{implementation} |
| 410 |
% |
| 411 |
% \section{\pkg{\ExplFileName} implementation} |
| 412 |
% |
| 413 |
% \begin{macrocode} |
| 414 |
%<*package> |
| 415 |
% \end{macrocode} |
| 416 |
% |
| 417 |
% \begin{macrocode} |
| 418 |
%<@@=cellprops> |
| 419 |
% \end{macrocode} |
| 420 |
% |
| 421 |
% \begin{macrocode} |
| 422 |
\ProvidesExplPackage |
| 423 |
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} |
| 424 |
|
| 425 |
\RequirePackage{xparse} |
| 426 |
\RequirePackage{xcolor} |
| 427 |
\RequirePackage{etoolbox} |
| 428 |
% \end{macrocode} |
| 429 |
% |
| 430 |
% \subsection{Loading and fixing \pkg{mdwtab}} |
| 431 |
% |
| 432 |
% There is a bug in the command \cs{colpop} of \pkg{mdwtab}: instead of just |
| 433 |
% popping one name in the stack of column sets currently used, it empties it |
| 434 |
% completely because one \cs{expandafter} is missing. This is proof that not |
| 435 |
% many package authors really use this API as recommended by Mark |
| 436 |
% \textsc{Wooding}\ldots We thus load \pkg{mdwtab} and fix \cs{colpop}. |
| 437 |
% |
| 438 |
% \begin{macrocode} |
| 439 |
\RequirePackage{mdwtab} |
| 440 |
\cs_set_nopar:Npn \tab@pop #1 { \tl_set:Nx #1 { \tl_tail:N #1 } } |
| 441 |
% \end{macrocode} |
| 442 |
% |
| 443 |
% \subsection{Parsing CSS properties} |
| 444 |
% |
| 445 |
% Properties are parsed once at setting time, by expandable parsers that leave |
| 446 |
% definitions in the input stream. All these resulting definitions are saved |
| 447 |
% in a token list that will be expanded when we need the values. The goal is |
| 448 |
% to have multiple token lists for multiple contexts, yet not to do the full |
| 449 |
% parsing dance once per cell. |
| 450 |
% |
| 451 |
% \begin{variable}{\l_@@_property_value_<name>_tl} |
| 452 |
% \begin{macro}{\@@_generic_setter:nnn} |
| 453 |
% \begin{macro}{\@@_get_property:n} |
| 454 |
% \begin{macro}{\@@_get_property:nN} |
| 455 |
% We first define a generic setter which just uses |
| 456 |
% \cs{l_@@_property_value_<name>_tl} to store the value of the property. We |
| 457 |
% define getters, one that leaves the value in the stream, and one saving the |
| 458 |
% value in a token list. |
| 459 |
% |
| 460 |
% \begin{macrocode} |
| 461 |
\cs_new:Nn \@@_generic_setter:nnn { |
| 462 |
\exp_not:N \tl_set:Nn |
| 463 |
\exp_not:c { l_@@_property_value_#2_tl } |
| 464 |
{#1 {#3}} |
| 465 |
} |
| 466 |
|
| 467 |
\cs_set_nopar:Nn \@@_get_property:n { |
| 468 |
\tl_use:c { l_@@_property_value_#1_tl } |
| 469 |
} |
| 470 |
|
| 471 |
\cs_new_protected_nopar:Nn \@@_get_property:nN { |
| 472 |
\tl_if_exist:cTF { l_@@_property_value_#1_tl } { |
| 473 |
\tl_set_eq:Nc #2 { l_@@_property_value_#1_tl } |
| 474 |
}{ |
| 475 |
\tl_clear:N #2 |
| 476 |
} |
| 477 |
} |
| 478 |
% \end{macrocode} |
| 479 |
% |
| 480 |
% \end{macro} |
| 481 |
% \end{macro} |
| 482 |
% \end{macro} |
| 483 |
% \end{variable} |
| 484 |
% |
| 485 |
% \begin{macro}{\@@_property_type_<name>:nn} |
| 486 |
% \begin{macro}{\@@_define_properties:nn} |
| 487 |
% The control sequence \cs{_@@_property_type_<name>:nn} holds the setter for |
| 488 |
% the property \meta{name}. It can be set by the following helper: |
| 489 |
% |
| 490 |
% \begin{macrocode} |
| 491 |
\cs_new_protected:Nn \@@_define_properties:nn { |
| 492 |
\clist_map_inline:nn {#2} { |
| 493 |
\cs_set:cpn { _@@_property_type_##1:nn } {#1} |
| 494 |
} |
| 495 |
} |
| 496 |
% \end{macrocode} |
| 497 |
% |
| 498 |
% \end{macro} |
| 499 |
% \end{macro} |
| 500 |
% |
| 501 |
% \begin{macro}{\@@_use_setter:nn} |
| 502 |
% Sometimes we need to use a setter right away rather than save its action |
| 503 |
% somewhere. The following helper does that with an x-expansion. |
| 504 |
% |
| 505 |
% \begin{macrocode} |
| 506 |
\cs_new:Nn \@@_delegate_setter:nn { |
| 507 |
\use:c {_@@_property_type_#1:nn} {#1} {#2} |
| 508 |
} |
| 509 |
\cs_new_protected:Nn \@@_use_setter:nn { |
| 510 |
\use:x { |
| 511 |
\@@_delegate_setter:nn {#1} {#2} |
| 512 |
} |
| 513 |
} |
| 514 |
% \end{macrocode} |
| 515 |
% |
| 516 |
% \end{macro} |
| 517 |
% |
| 518 |
% \begin{macro}{\@@_parse_properties:nn} |
| 519 |
% Now we can parse the block of properties for a given selector. The first |
| 520 |
% argument is the token list variable which will ultimately hold the expanded |
| 521 |
% code setting internal variables from the properties. That code will be |
| 522 |
% called when recalling the computed values in a specific context. |
| 523 |
% |
| 524 |
% \begin{macrocode} |
| 525 |
\cs_new_protected:Nn \@@_parse_properties:Nn { |
| 526 |
\tl_clear:N #1 |
| 527 |
\seq_set_split:Nnn \l_tmpa_seq {;} {#2} |
| 528 |
\seq_map_inline:Nn \l_tmpa_seq { |
| 529 |
\tl_if_empty:nF {##1} { |
| 530 |
\exp_args:NNV \seq_set_split:Nnn \l_tmpb_seq \c_colon_str {##1} |
| 531 |
\int_compare:nNnT {\seq_count:N \l_tmpb_seq} = { 2 } { |
| 532 |
\seq_get_left:NN \l_tmpb_seq \l_tmpa_tl |
| 533 |
\exp_args:NNV \str_set:Nn \l_tmpa_str \l_tmpa_tl |
| 534 |
\seq_get_right:NN \l_tmpb_seq \l_tmpa_tl |
| 535 |
\cs_if_exist:cT { _@@_property_type_\l_tmpa_str :nn } { |
| 536 |
\tl_put_right:Nx #1 { |
| 537 |
\exp_args:NVV \@@_delegate_setter:nn |
| 538 |
\l_tmpa_str \l_tmpa_tl |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
} |
| 543 |
} |
| 544 |
} |
| 545 |
% \end{macrocode} |
| 546 |
% \end{macro} |
| 547 |
% |
| 548 |
% \subsection{Defining new properties} |
| 549 |
% |
| 550 |
% \subsubsection{Some helpers} |
| 551 |
% |
| 552 |
% \begin{macro}{\@@_fourval_setter:nnnnnn} |
| 553 |
% \begin{macro}{\@@_define_fourval_properties:nnnnnn} |
| 554 |
% We first define helpers to parse and define compound properties like |
| 555 |
% "padding" where you can give one to four different values and the missing |
| 556 |
% values are copied from the given ones. |
| 557 |
% |
| 558 |
% \begin{macrocode} |
| 559 |
\cs_new:Nn \@@_fourval_setter:nnnnnn { |
| 560 |
\@@_fourval_setter_aux:w |
| 561 |
{#1}{#2}{#3}{#4}#6~{\q_no_value}~{\q_no_value}~{\q_no_value}~\q_stop |
| 562 |
} |
| 563 |
\cs_new:Npn \@@_fourval_setter_aux:w #1#2#3#4#5~#6~#7~#8~#9\q_stop { |
| 564 |
\@@_delegate_setter:nn {#1} {#5} |
| 565 |
\quark_if_no_value:nTF {#6} { |
| 566 |
\@@_delegate_setter:nn {#2} {#5} |
| 567 |
\@@_delegate_setter:nn {#4} {#5} |
| 568 |
}{ |
| 569 |
\@@_delegate_setter:nn {#2} {#6} |
| 570 |
\quark_if_no_value:nTF {#8} { |
| 571 |
\@@_delegate_setter:nn {#4} {#6} |
| 572 |
}{ |
| 573 |
\@@_delegate_setter:nn {#4} {#8} |
| 574 |
} |
| 575 |
} |
| 576 |
\quark_if_no_value:nTF {#7} { |
| 577 |
\@@_delegate_setter:nn {#3} {#5} |
| 578 |
}{ |
| 579 |
\@@_delegate_setter:nn {#3} {#7} |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
\cs_new_protected:Nn \@@_define_fourval_properties:nnnnnn { |
| 584 |
\@@_define_properties:nn {#1} { #3, #4, #5, #6 } |
| 585 |
\@@_define_properties:nn { |
| 586 |
\@@_fourval_setter:nnnnnn {#3}{#4}{#5}{#6} |
| 587 |
}{ |
| 588 |
#2 |
| 589 |
} |
| 590 |
} |
| 591 |
% \end{macrocode} |
| 592 |
% \end{macro} |
| 593 |
% \end{macro} |
| 594 |
% |
| 595 |
% \begin{macro}{\@@_color_setter:nn} |
| 596 |
% This macro is used to parse color definitions, either named, rgb, or hsl. |
| 597 |
% |
| 598 |
% \begin{macrocode} |
| 599 |
\tl_const:Nn \c_@@_inherit_color_tl { \q_nil } |
| 600 |
|
| 601 |
\cs_new_nopar:Nn \@@_color_setter:nn { |
| 602 |
\str_if_eq:nnTF {#2} {inherit} { |
| 603 |
\@@_generic_setter:nnn \exp_not:n {#1} {\c_@@_inherit_color_tl} |
| 604 |
}{ |
| 605 |
\str_case_e:nnF { \str_range:nnn {#2} {1} {4} } { |
| 606 |
{rgb(} { |
| 607 |
\@@_generic_setter:nnn \use:n {#1} { |
| 608 |
\exp_not:n {\color[RGB]} {\str_range:nnn {#2} {5} {-2}} |
| 609 |
}} |
| 610 |
{hsl(} { |
| 611 |
\@@_generic_setter:nnn \use:n {#1} { |
| 612 |
\exp_not:n {\color[Hsb]} {\str_range:nnn {#2} {5} {-2}} |
| 613 |
}} |
| 614 |
}{ |
| 615 |
\@@_generic_setter:nnn \exp_not:n {#1} { |
| 616 |
\color{#2} |
| 617 |
} |
| 618 |
} |
| 619 |
} |
| 620 |
} |
| 621 |
% \end{macrocode} |
| 622 |
% \end{macro} |
| 623 |
% |
| 624 |
% \begin{macro}{\@@_bgcolor_setter:nn} |
| 625 |
% For background colors, we support "transparent" as an alias for "inherit". |
| 626 |
% |
| 627 |
% \begin{macrocode} |
| 628 |
\cs_new_nopar:Nn \@@_bgcolor_setter:nn { |
| 629 |
\str_if_eq:nnTF {#2} {transparent} { |
| 630 |
\@@_color_setter:nn {#1} {inherit} |
| 631 |
}{ |
| 632 |
\@@_color_setter:nn {#1} {#2} |
| 633 |
} |
| 634 |
} |
| 635 |
% \end{macrocode} |
| 636 |
% \end{macro} |
| 637 |
% |
| 638 |
% \begin{macro}{\@@_linewidth_setter:nn} |
| 639 |
% A setter for line widths that supports common keywords: |
| 640 |
% |
| 641 |
% \begin{macrocode} |
| 642 |
\cs_new_nopar:Nn \@@_linewidth_setter:nn { |
| 643 |
\str_case:nnF {#2} { |
| 644 |
{thin} { \@@_generic_setter:nnn \exp_not:n {#1} { \fboxrule} } |
| 645 |
{medium} { \@@_generic_setter:nnn \exp_not:n {#1} { 2\fboxrule} } |
| 646 |
{thick} { \@@_generic_setter:nnn \exp_not:n {#1} { 3\fboxrule} } |
| 647 |
}{ |
| 648 |
\@@_generic_setter:nnn \exp_not:n {#1} {#2} |
| 649 |
} |
| 650 |
} |
| 651 |
% \end{macrocode} |
| 652 |
% \end{macro} |
| 653 |
% |
| 654 |
% \begin{macro}{\@@_border_setter:nn } |
| 655 |
% "border" and "border-"<side> are compound properties that can define the |
| 656 |
% width, the style and the color. As per the specification, the "border" |
| 657 |
% property always sets all four sides at the same time instead of being a |
| 658 |
% four-valued property. |
| 659 |
% |
| 660 |
% \begin{macrocode} |
| 661 |
\cs_new_nopar:Nn \@@_border_setter:nn { |
| 662 |
\@@_border_setter_aux:nw |
| 663 |
{#1}#2~{\q_no_value}~{\q_no_value}~\q_stop |
| 664 |
} |
| 665 |
\cs_new:Npn \@@_border_setter_aux:nw #1#2~#3~#4~#5\q_stop { |
| 666 |
\quark_if_no_value:nTF {#4} { |
| 667 |
\@@_border_setter_isstyle:nTF {#2} { |
| 668 |
\@@_delegate_setter:nn {#1-width} {thin} |
| 669 |
\@@_delegate_setter:nn {#1-style} {#2} |
| 670 |
\quark_if_no_value:nTF {#3} { |
| 671 |
\@@_delegate_setter:nn {#1-color} {inherit} |
| 672 |
}{ |
| 673 |
\@@_delegate_setter:nn {#1-color} {#3} |
| 674 |
} |
| 675 |
}{ |
| 676 |
\quark_if_no_value:nTF {#3} { |
| 677 |
%% One no-style value, ambiguous. Ignore the property |
| 678 |
}{ |
| 679 |
\@@_border_setter_isstyle:nTF {#3} { |
| 680 |
\@@_delegate_setter:nn {#1-width} {#2} |
| 681 |
\@@_delegate_setter:nn {#1-style} {#3} |
| 682 |
\@@_delegate_setter:nn {#1-color} {inherit} |
| 683 |
}{ |
| 684 |
\@@_delegate_setter:nn {#1-width} {#2} |
| 685 |
\@@_delegate_setter:nn {#1-style} {none} |
| 686 |
\@@_delegate_setter:nn {#1-color} {#3} |
| 687 |
} |
| 688 |
} |
| 689 |
} |
| 690 |
}{ |
| 691 |
\@@_delegate_setter:nn {#1-width} {#2} |
| 692 |
\@@_delegate_setter:nn {#1-style} {#3} |
| 693 |
\@@_delegate_setter:nn {#1-color} {#4} |
| 694 |
} |
| 695 |
} |
| 696 |
|
| 697 |
\cs_new:Npn \@@_border_setter_isstyle:nTF #1 { |
| 698 |
\str_case:nnTF {#1} { |
| 699 |
{none}{} {hidden}{} {dotted}{} {dashed}{} {solid}{} |
| 700 |
{double}{} {groove}{} {ridge}{} {inset}{} {outset}{} |
| 701 |
} |
| 702 |
} |
| 703 |
% \end{macrocode} |
| 704 |
% \end{macro} |
| 705 |
% |
| 706 |
% \subsubsection{Actual definitions of properties} |
| 707 |
% |
| 708 |
% First some simple-valued properties where we just store the value |
| 709 |
% unexpanded. |
| 710 |
% |
| 711 |
% \begin{macrocode} |
| 712 |
\@@_define_properties:nn { |
| 713 |
\@@_generic_setter:nnn \exp_not:n |
| 714 |
}{ |
| 715 |
min-height, |
| 716 |
min-depth, |
| 717 |
min-width, |
| 718 |
} |
| 719 |
% \end{macrocode} |
| 720 |
% |
| 721 |
% "padding" is a compound property for "padding-"<side> which store their |
| 722 |
% value unexpanded. |
| 723 |
% |
| 724 |
% \begin{macrocode} |
| 725 |
\@@_define_fourval_properties:nnnnnn |
| 726 |
{ \@@_generic_setter:nnn \exp_not:n } |
| 727 |
{padding} |
| 728 |
{padding-top}{padding-right}{padding-bottom}{padding-left} |
| 729 |
% \end{macrocode} |
| 730 |
% |
| 731 |
% Simple-valued properties that store a str value. |
| 732 |
% |
| 733 |
% \begin{macrocode} |
| 734 |
\@@_define_properties:nn { |
| 735 |
\@@_generic_setter:nnn \tl_to_str:n |
| 736 |
}{ |
| 737 |
text-align, |
| 738 |
vertical-align, |
| 739 |
math-mode, |
| 740 |
} |
| 741 |
% \end{macrocode} |
| 742 |
% |
| 743 |
% Some simple-valued color properties, using the dedicated parser. |
| 744 |
% |
| 745 |
% \begin{macrocode} |
| 746 |
\@@_define_properties:nn { |
| 747 |
\@@_color_setter:nn |
| 748 |
}{ |
| 749 |
color, |
| 750 |
} |
| 751 |
|
| 752 |
\@@_define_properties:nn { |
| 753 |
\@@_bgcolor_setter:nn |
| 754 |
}{ |
| 755 |
background-color, |
| 756 |
} |
| 757 |
% \end{macrocode} |
| 758 |
% |
| 759 |
% A compound property whose individual sides use the linewidth setter for |
| 760 |
% keyword recognition. |
| 761 |
% |
| 762 |
% \begin{macrocode} |
| 763 |
\@@_define_fourval_properties:nnnnnn |
| 764 |
{ \@@_linewidth_setter:nn } |
| 765 |
{border-width} |
| 766 |
{border-top-width}{border-right-width} |
| 767 |
{border-bottom-width}{border-left-width} |
| 768 |
% \end{macrocode} |
| 769 |
% |
| 770 |
% A compound property whose individual sides are str values. They could be |
| 771 |
% checked against the list of valid values, but any non-existing one will be |
| 772 |
% ignored anyway due to the way they are implemented. |
| 773 |
% |
| 774 |
% \begin{macrocode} |
| 775 |
\@@_define_fourval_properties:nnnnnn |
| 776 |
{ \@@_generic_setter:nnn \tl_to_str:n } |
| 777 |
{border-style} |
| 778 |
{border-top-style}{border-right-style} |
| 779 |
{border-bottom-style}{border-left-style} |
| 780 |
% \end{macrocode} |
| 781 |
% |
| 782 |
% A compound property whose individual sides are colors. |
| 783 |
% |
| 784 |
% \begin{macrocode} |
| 785 |
\@@_define_fourval_properties:nnnnnn |
| 786 |
{ \@@_color_setter:nn } |
| 787 |
{border-color} |
| 788 |
{border-top-color}{border-right-color} |
| 789 |
{border-bottom-color}{border-left-color} |
| 790 |
% \end{macrocode} |
| 791 |
% |
| 792 |
% The five border-specific compound properties are defined here. |
| 793 |
% |
| 794 |
% \begin{macrocode} |
| 795 |
\@@_define_properties:nn { |
| 796 |
\@@_border_setter:nn |
| 797 |
}{ |
| 798 |
border, border-top, border-right, border-bottom, border-left |
| 799 |
} |
| 800 |
% \end{macrocode} |
| 801 |
% |
| 802 |
% \subsection{Parsing a CSS stylesheet} |
| 803 |
% |
| 804 |
% \begin{macrocode} |
| 805 |
\NewDocumentCommand \cellprops { m } { |
| 806 |
\@@_parse_css:n {#1} |
| 807 |
} |
| 808 |
|
| 809 |
\cs_new_protected:Nn \@@_parse_css:n { |
| 810 |
\@@_parse_css:w #1 \q_mark {\q_nil} \q_stop |
| 811 |
% \end{macrocode} |
| 812 |
% |
| 813 |
% Ensure the already seen specificities is in order without duplicates. |
| 814 |
% |
| 815 |
% \begin{macrocode} |
| 816 |
\seq_remove_duplicates:N \l_@@_specificities_seq |
| 817 |
\seq_sort:Nn \l_@@_specificities_seq { |
| 818 |
\int_compare:nNnTF { ##1 } > { ##2 } |
| 819 |
{ \sort_return_swapped: } |
| 820 |
{ \sort_return_same: } |
| 821 |
} |
| 822 |
} |
| 823 |
% \end{macrocode} |
| 824 |
% |
| 825 |
% Grab the content up to the first opening brace. That content will be the |
| 826 |
% comma-separated selector list, and the braced content is a block of |
| 827 |
% properties. We can loop until there is no such block remaining. |
| 828 |
% |
| 829 |
% \begin{macrocode} |
| 830 |
\tl_new:N \l_@@_parse_properties_tl |
| 831 |
\NewDocumentCommand \@@_parse_css:w { lmu{\q_stop} } { |
| 832 |
\quark_if_nil:nF {#2} { |
| 833 |
\@@_parse_properties:Nn \l_@@_parse_properties_tl {#2} |
| 834 |
\clist_map_inline:nn {#1} { |
| 835 |
\tl_if_empty:nF {##1} { \@@_parse_css_addprops:n {##1} } |
| 836 |
} |
| 837 |
\@@_parse_css:w #3 \q_stop |
| 838 |
} |
| 839 |
} |
| 840 |
% \end{macrocode} |
| 841 |
% |
| 842 |
% Some pseudo-classes generate conditional code for the properties to be |
| 843 |
% applied. Check if such code exists, and wrap the parsed property setters |
| 844 |
% in a \cs{bool_if:nT}. |
| 845 |
% |
| 846 |
% \begin{macrocode} |
| 847 |
\tl_new:N \l_@@_current_selector_tl |
| 848 |
\tl_new:N \l_@@_current_selector_check_tl |
| 849 |
\cs_new_protected:Nn \@@_parse_css_addprops:n { |
| 850 |
\@@_parse_selector:n {#1} |
| 851 |
\tl_if_empty:NF \l_@@_current_selector_tl { |
| 852 |
\tl_set:Nx \l_tmpa_tl |
| 853 |
{ l_@@_property_group_\l_@@_current_selector_tl _tl } |
| 854 |
\tl_if_exist:cF { \l_tmpa_tl } { \tl_clear:c { \l_tmpa_tl } } |
| 855 |
\tl_if_empty:NTF \l_@@_current_selector_check_tl { |
| 856 |
\tl_put_right:cV { \l_tmpa_tl } \l_@@_parse_properties_tl |
| 857 |
}{ |
| 858 |
\tl_put_right:cx { \l_tmpa_tl } { |
| 859 |
\exp_not:N \bool_if:nT { |
| 860 |
\exp_not:V \l_@@_current_selector_check_tl |
| 861 |
}{ |
| 862 |
\exp_not:V \l_@@_parse_properties_tl |
| 863 |
} |
| 864 |
} |
| 865 |
} |
| 866 |
} |
| 867 |
} |
| 868 |
% \end{macrocode} |
| 869 |
% |
| 870 |
% Here we parse a selector. These are naturally space-separated, but we first |
| 871 |
% need to detect and normalize constructs like ":nth-child(argument)". We |
| 872 |
% replace them by ":nth-child{argument}" where the braces will procect any |
| 873 |
% space that can legitimately occur within "argument". |
| 874 |
% |
| 875 |
% \begin{macrocode} |
| 876 |
\cs_new_protected:Nn \@@_parse_selector_sanitize:n { |
| 877 |
\exp_args:Nx \@@_parse_selector_sanitize_aux:n |
| 878 |
{ \tl_to_str:n{#1} } |
| 879 |
} |
| 880 |
\cs_new_protected:Nn \@@_parse_selector_sanitize_aux:n { |
| 881 |
\cs_set:Npn \@@_parse_selector_sanitize:w ##1:#1(##2)##3\q_stop |
| 882 |
{ |
| 883 |
\quark_if_nil:nTF {##3} { |
| 884 |
##1 |
| 885 |
}{ |
| 886 |
##1:#1{##2}\@@_parse_selector_sanitize:w ##3\q_stop |
| 887 |
} |
| 888 |
} |
| 889 |
\tl_set:Nx \l_@@_current_selector_tl { |
| 890 |
\exp_last_unbraced:NV |
| 891 |
\@@_parse_selector_sanitize:w |
| 892 |
\l_@@_current_selector_tl |
| 893 |
:#1()\q_nil\q_stop |
| 894 |
} |
| 895 |
} |
| 896 |
% \end{macrocode} |
| 897 |
% |
| 898 |
% Now that we can sanitize pseudo-classes, parsing the selector is safe. The |
| 899 |
% constructs to protect are ":nth-child()" and ":where()" since other supported |
| 900 |
% pseudo-classes have no argument. |
| 901 |
% |
| 902 |
% \begin{macrocode} |
| 903 |
\seq_new:N \l_@@_current_selector_seq |
| 904 |
\seq_new:N \l_@@_pseudoclasses_seq |
| 905 |
\tl_new:N \l_@@_current_element_tl |
| 906 |
\tl_new:N \l_@@_current_tableclass_tl |
| 907 |
\int_new:N \l_@@_current_level_int |
| 908 |
\int_new:N \l_@@_current_specificity_int |
| 909 |
\seq_new:N \l_@@_specificities_seq |
| 910 |
\cs_new_protected:Nn \@@_parse_selector:n { |
| 911 |
\tl_set:Nx \l_@@_current_selector_tl { \tl_to_str:n {#1} } |
| 912 |
% \end{macrocode} |
| 913 |
% |
| 914 |
% The sanitize code is more readable with Expl category colon, so replace it |
| 915 |
% now, instead of defining the method with expand or lccode tricks. |
| 916 |
% |
| 917 |
% \begin{macrocode} |
| 918 |
\exp_args:NNV \tl_replace_all:Nnn |
| 919 |
\l_@@_current_selector_tl \c_colon_str {:} |
| 920 |
\@@_parse_selector_sanitize:n {nth-child} |
| 921 |
\@@_parse_selector_sanitize:n {where} |
| 922 |
\seq_set_split:NnV \l_@@_current_selector_seq {~} \l_@@_current_selector_tl |
| 923 |
\tl_clear:N \l_@@_current_selector_tl |
| 924 |
\tl_clear:N \l_@@_current_selector_check_tl |
| 925 |
\tl_clear:N \l_@@_current_tableclass_tl |
| 926 |
\int_set:Nn \l_@@_current_level_int {-1} |
| 927 |
\int_zero:N \l_@@_current_specificity_int |
| 928 |
\seq_map_inline:Nn \l_@@_current_selector_seq { |
| 929 |
\tl_clear:N \l_@@_current_element_tl |
| 930 |
\@@_parse_simple_selector:n {##1} |
| 931 |
} |
| 932 |
% \end{macrocode} |
| 933 |
% |
| 934 |
% Remember the current selector as "<last element>~<specificity>". |
| 935 |
% |
| 936 |
% \begin{macrocode} |
| 937 |
\tl_if_empty:NF \l_@@_current_element_tl { |
| 938 |
\tl_if_empty:NF \l_@@_current_tableclass_tl { |
| 939 |
\tl_set:Nx \l_@@_current_tableclass_tl { |
| 940 |
l_@@_active_classes_\l_@@_current_tableclass_tl _bool |
| 941 |
} |
| 942 |
\bool_if_exist:cF { \l_@@_current_tableclass_tl } { |
| 943 |
\bool_new:c { \l_@@_current_tableclass_tl } |
| 944 |
} |
| 945 |
\@@_add_check:x { |
| 946 |
\exp_not:n { \bool_if_p:N } |
| 947 |
{ |
| 948 |
\exp_not:c { \l_@@_current_tableclass_tl } |
| 949 |
} |
| 950 |
} |
| 951 |
} |
| 952 |
\tl_set:Nx \l_@@_current_selector_tl { |
| 953 |
\exp_not:V \l_@@_current_element_tl |
| 954 |
\exp_not:n {~} |
| 955 |
\int_use:N \l_@@_current_specificity_int |
| 956 |
} |
| 957 |
\seq_put_right:Nx \l_@@_specificities_seq { |
| 958 |
\int_use:N \l_@@_current_specificity_int |
| 959 |
} |
| 960 |
} |
| 961 |
} |
| 962 |
|
| 963 |
\tl_new:N \l_@@_maybe_element_tl |
| 964 |
|
| 965 |
\cs_new_protected:Nn \@@_parse_simple_selector:n { |
| 966 |
% \end{macrocode} |
| 967 |
% |
| 968 |
% First we replace "." with ":." so that class selectors can be handled with |
| 969 |
% the same code as pseudo-classes. Then we split the current selector item on |
| 970 |
% ":" to get the base element and the pseudo-classes. |
| 971 |
% |
| 972 |
% \begin{macrocode} |
| 973 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 974 |
\tl_replace_all:Nnn \l_tmpa_tl {.} {:.} |
| 975 |
\seq_set_split:NnV \l_@@_pseudoclasses_seq {:} \l_tmpa_tl |
| 976 |
\seq_pop_left:NN \l_@@_pseudoclasses_seq \l_@@_maybe_element_tl |
| 977 |
% \end{macrocode} |
| 978 |
% |
| 979 |
% Known type selectors increase the specificity by one. |
| 980 |
% |
| 981 |
% \begin{macrocode} |
| 982 |
\str_case:VnTF \l_@@_maybe_element_tl { |
| 983 |
{ table } { \int_set:Nn \l_tmpa_int { 1 } } |
| 984 |
{ tr } { \int_set:Nn \l_tmpa_int { 2 } } |
| 985 |
{ td } { \int_set:Nn \l_tmpa_int { 3 } } |
| 986 |
{ p } { \int_set:Nn \l_tmpa_int { 4 } } |
| 987 |
}{ |
| 988 |
\int_add:Nn \l_@@_current_specificity_int { 1 } |
| 989 |
}{ |
| 990 |
% \end{macrocode} |
| 991 |
% |
| 992 |
% An empty type selector is accepted to account for ":where()" pseudo-classes. |
| 993 |
% They will be handled in the loop below, but of course there should be a type |
| 994 |
% selector eventually. Map that case to a big positive next level so that we can |
| 995 |
% detect that and keep the current level as-is. |
| 996 |
% |
| 997 |
% Unknown type selectors are mapped to big negative levels |
| 998 |
% so that the descendant check will refuse them, unless we are at the very |
| 999 |
% first type selector in which case we map the deprecated environment |
| 1000 |
% selector to a class selector. |
| 1001 |
% |
| 1002 |
% \begin{macrocode} |
| 1003 |
\tl_if_empty:NTF \l_@@_maybe_element_tl { |
| 1004 |
\int_set:Nn \l_tmpa_int { 10 } |
| 1005 |
}{ |
| 1006 |
\int_compare:nNnTF \l_@@_current_level_int = { -1 } { |
| 1007 |
\tl_set_eq:NN |
| 1008 |
\l_@@_current_tableclass_tl |
| 1009 |
\l_@@_maybe_element_tl |
| 1010 |
\tl_set:Nn \l_@@_maybe_element_tl { table } |
| 1011 |
\int_set:Nn \l_tmpa_int { 1 } |
| 1012 |
\int_add:Nn \l_@@_current_specificity_int { 11 } |
| 1013 |
}{ |
| 1014 |
\int_set:Nn \l_tmpa_int { -10 } |
| 1015 |
} |
| 1016 |
} |
| 1017 |
} |
| 1018 |
% \end{macrocode} |
| 1019 |
% |
| 1020 |
% If no type selector has been found yet, record the one we may have found |
| 1021 |
% now. Else, refuse to have two in the same selector. |
| 1022 |
% |
| 1023 |
% \begin{macrocode} |
| 1024 |
\tl_if_empty:NTF \l_@@_current_element_tl { |
| 1025 |
\tl_set_eq:NN \l_@@_current_element_tl \l_@@_maybe_element_tl |
| 1026 |
}{ |
| 1027 |
\tl_if_empty:NF \l_@@_maybe_element_tl { |
| 1028 |
\int_set:Nn \l_tmpa_int { -10 } |
| 1029 |
} |
| 1030 |
} |
| 1031 |
% \end{macrocode} |
| 1032 |
% |
| 1033 |
% If the detected element is a descendent of the previous one, the selector |
| 1034 |
% can match; count the element selector specificity and parse its |
| 1035 |
% pseudo-classes. If not, the whole selector cannot match and we discard it |
| 1036 |
% early. |
| 1037 |
% |
| 1038 |
% \begin{macrocode} |
| 1039 |
\int_compare:nNnTF \l_tmpa_int > \l_@@_current_level_int { |
| 1040 |
\int_compare:nNnT \l_tmpa_int < 10 { |
| 1041 |
\int_set_eq:NN \l_@@_current_level_int \l_tmpa_int |
| 1042 |
} |
| 1043 |
\seq_map_inline:Nn \l_@@_pseudoclasses_seq { |
| 1044 |
\@@_parse_pseudoclass:w ##1{}\q_stop |
| 1045 |
} |
| 1046 |
}{ |
| 1047 |
\tl_clear:N \l_@@_current_element_tl |
| 1048 |
} |
| 1049 |
% \end{macrocode} |
| 1050 |
% |
| 1051 |
% At the end of the selector parsing, the current element should not be empty. |
| 1052 |
% |
| 1053 |
% \begin{macrocode} |
| 1054 |
\tl_if_empty:NT \l_@@_current_element_tl { |
| 1055 |
\seq_map_break: |
| 1056 |
} |
| 1057 |
} |
| 1058 |
% \end{macrocode} |
| 1059 |
% |
| 1060 |
% The first argument is the complete pseudo-class up to the opening argument |
| 1061 |
% brace (if any), and the second argument is the braced content (if any). |
| 1062 |
% The third argument gobbles any trailing garbage. |
| 1063 |
% |
| 1064 |
% If the pseudo-class starts with a "." this is a class selector. Else, this |
| 1065 |
% is an unknown pseudo-class and we reject the complete selector. |
| 1066 |
% |
| 1067 |
% \begin{macrocode} |
| 1068 |
\NewDocumentCommand \@@_parse_pseudoclass:w { lmu{\q_stop} } { |
| 1069 |
\str_case:nnF { #1 } { |
| 1070 |
{first-child} { \@@_parse_selector_nth:n {1} } |
| 1071 |
{nth-child} { \@@_parse_selector_nth:n {#2} } |
| 1072 |
{where} { \@@_parse_where:n {#2} } |
| 1073 |
}{ |
| 1074 |
\str_if_eq:eeTF { \str_head:n { #1 } } {.} { |
| 1075 |
\tl_set:Nx \l_@@_current_tableclass_tl { |
| 1076 |
\str_tail:n { #1 } |
| 1077 |
} |
| 1078 |
\int_add:Nn \l_@@_current_specificity_int { 10 } |
| 1079 |
}{ |
| 1080 |
\tl_clear:N \l_@@_current_element_tl |
| 1081 |
\seq_map_break:n { \seq_map_break: } |
| 1082 |
} |
| 1083 |
} |
| 1084 |
} |
| 1085 |
|
| 1086 |
\str_const:Nn \c_@@_parse_n_str {n} |
| 1087 |
\int_new:N \l_@@_nth_coeff_int |
| 1088 |
\int_new:N \l_@@_nth_offset_int |
| 1089 |
\cs_new_protected:Nn \@@_parse_selector_nth:n { |
| 1090 |
% \end{macrocode} |
| 1091 |
% |
| 1092 |
% Count the pseudo-class in the specificity. |
| 1093 |
% |
| 1094 |
% \begin{macrocode} |
| 1095 |
\int_add:Nn \l_@@_current_specificity_int { 10 } |
| 1096 |
% \end{macrocode} |
| 1097 |
% |
| 1098 |
% Now parse the nth-child argument: |
| 1099 |
% |
| 1100 |
% \begin{macrocode} |
| 1101 |
\str_case:nnF {#1} { |
| 1102 |
{even} { \str_set:Nn \l_tmpa_str {2n} } |
| 1103 |
{odd} { \str_set:Nn \l_tmpa_str {2n+1} } |
| 1104 |
}{ |
| 1105 |
\str_set:Nn \l_tmpa_str {#1} |
| 1106 |
} |
| 1107 |
\exp_args:NNV |
| 1108 |
\seq_set_split:NnV \l_tmpa_seq \c_@@_parse_n_str \l_tmpa_str |
| 1109 |
\seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl |
| 1110 |
\tl_if_empty:NTF \l_tmpa_tl { |
| 1111 |
\int_zero:N \l_@@_nth_offset_int |
| 1112 |
}{ |
| 1113 |
\int_set:Nn \l_@@_nth_offset_int { \l_tmpa_tl } |
| 1114 |
} |
| 1115 |
\seq_get_left:NNTF \l_tmpa_seq \l_tmpa_tl { |
| 1116 |
\tl_if_empty:NTF \l_tmpa_tl { |
| 1117 |
\int_set:Nn \l_@@_nth_coeff_int {1} |
| 1118 |
}{ |
| 1119 |
\exp_args:NV \tl_if_eq:nnTF \l_tmpa_tl {-} { |
| 1120 |
\int_set:Nn \l_@@_nth_coeff_int {-1} |
| 1121 |
}{ |
| 1122 |
\int_set:Nn \l_@@_nth_coeff_int { \l_tmpa_tl } |
| 1123 |
} |
| 1124 |
} |
| 1125 |
}{ |
| 1126 |
\int_zero:N \l_@@_nth_coeff_int |
| 1127 |
} |
| 1128 |
% \end{macrocode} |
| 1129 |
% |
| 1130 |
% At last, generate the condition code. |
| 1131 |
% |
| 1132 |
% \begin{macrocode} |
| 1133 |
\str_case:Vn \l_@@_current_element_tl { |
| 1134 |
{tr} { \@@_generate_check_nth:n {\g_@@_row_int} } |
| 1135 |
{td} { \@@_generate_check_nth:n {\g_@@_col_int} } |
| 1136 |
} |
| 1137 |
} |
| 1138 |
|
| 1139 |
\cs_new_protected_nopar:Nn \@@_generate_check_nth:n { |
| 1140 |
\int_compare:nNnTF \l_@@_nth_coeff_int = { 0 } { |
| 1141 |
\@@_add_check:x { |
| 1142 |
\exp_not:n { \int_compare_p:nNn #1 = } |
| 1143 |
{ |
| 1144 |
\exp_not:V \l_@@_nth_offset_int |
| 1145 |
} |
| 1146 |
} |
| 1147 |
}{ |
| 1148 |
\tl_set:Nx \l_tmpb_tl { |
| 1149 |
{ |
| 1150 |
\exp_not:n { #1 - } |
| 1151 |
\exp_not:V \l_@@_nth_offset_int |
| 1152 |
}{ |
| 1153 |
\exp_not:V \l_@@_nth_coeff_int |
| 1154 |
} |
| 1155 |
} |
| 1156 |
\@@_add_check:x { |
| 1157 |
\exp_not:N \bool_lazy_and_p:nn { |
| 1158 |
\exp_not:n { \int_compare_p:nNn 0 = } |
| 1159 |
{ |
| 1160 |
\exp_not:N \int_mod:nn |
| 1161 |
\exp_not:V \l_tmpb_tl |
| 1162 |
} |
| 1163 |
}{ |
| 1164 |
\exp_not:n { \int_compare_p:nNn 0 < } |
| 1165 |
{ |
| 1166 |
\exp_not:N \int_div_truncate:nn |
| 1167 |
\exp_not:V \l_tmpb_tl |
| 1168 |
\exp_not:n { + 1 } |
| 1169 |
} |
| 1170 |
} |
| 1171 |
} |
| 1172 |
} |
| 1173 |
} |
| 1174 |
|
| 1175 |
\cs_new_protected:Nn \@@_parse_where:n { |
| 1176 |
\use:x { |
| 1177 |
\exp_not:n { |
| 1178 |
\@@_parse_simple_selector:n { #1 } |
| 1179 |
\int_set:Nn \l_@@_current_specificity_int |
| 1180 |
} |
| 1181 |
{ |
| 1182 |
\int_use:N \l_@@_current_specificity_int |
| 1183 |
} |
| 1184 |
} |
| 1185 |
} |
| 1186 |
|
| 1187 |
\cs_new_protected:Nn \@@_add_check:n { |
| 1188 |
\tl_if_empty:NTF \l_@@_current_selector_check_tl { |
| 1189 |
\tl_set:Nn \l_@@_current_selector_check_tl { #1 } |
| 1190 |
}{ |
| 1191 |
\tl_set:Nx \l_@@_current_selector_check_tl { |
| 1192 |
\exp_not:N \bool_lazy_and_p:nn { |
| 1193 |
\exp_not:V \l_@@_current_selector_check_tl |
| 1194 |
}{ |
| 1195 |
\exp_not:n { #1 } |
| 1196 |
} |
| 1197 |
} |
| 1198 |
} |
| 1199 |
} |
| 1200 |
\cs_generate_variant:Nn \@@_add_check:n {x} |
| 1201 |
|
| 1202 |
\seq_new:N \l_@@_classes_seq |
| 1203 |
\NewDocumentCommand \cellpropsclass { sm } { |
| 1204 |
\seq_set_split:Nnn \l_@@_classes_seq {~} { #2 } |
| 1205 |
\IfBooleanF {#1} { |
| 1206 |
\seq_put_right:Nn \l_@@_classes_seq { \@currenvir } |
| 1207 |
} |
| 1208 |
} |
| 1209 |
\cellpropsclass{} |
| 1210 |
|
| 1211 |
\cs_set_protected:Nn \@@_recall_properties:n { |
| 1212 |
\seq_map_inline:Nn \l_@@_specificities_seq { |
| 1213 |
\tl_if_exist:cT { l_@@_property_group_#1~##1_tl } { |
| 1214 |
\tl_use:c { l_@@_property_group_#1~##1_tl } |
| 1215 |
} |
| 1216 |
} |
| 1217 |
} |
| 1218 |
|
| 1219 |
\dim_new:N \l_@@_colsep_dim |
| 1220 |
\dim_new:N \l_@@_strut_ht_dim |
| 1221 |
\dim_new:N \l_@@_strut_dp_dim |
| 1222 |
|
| 1223 |
\ExplSyntaxOff |
| 1224 |
\cellprops{ |
| 1225 |
:where(td) { |
| 1226 |
padding: 0pt \csname l_@@_colsep_dim\endcsname; |
| 1227 |
min-height: \csname l_@@_strut_ht_dim\endcsname; |
| 1228 |
min-depth: \csname l_@@_strut_dp_dim\endcsname; |
| 1229 |
min-width: 0pt; |
| 1230 |
text-align: left; |
| 1231 |
vertical-align: baseline; |
| 1232 |
math-mode: auto; |
| 1233 |
color: inherit; |
| 1234 |
background-color: transparent; |
| 1235 |
border: thin none inherit; |
| 1236 |
} |
| 1237 |
:where(tr) { |
| 1238 |
color: inherit; |
| 1239 |
background-color: transparent; |
| 1240 |
} |
| 1241 |
:where(table) { |
| 1242 |
padding: 0pt; % No change at load time |
| 1243 |
color: inherit; |
| 1244 |
background-color: transparent; |
| 1245 |
} |
| 1246 |
} |
| 1247 |
\ExplSyntaxOn |
| 1248 |
|
| 1249 |
\int_new:N \g_@@_row_int |
| 1250 |
\int_new:N \g_@@_col_int |
| 1251 |
\bool_new:N \g_@@_inrow_bool |
| 1252 |
\bool_gset_false:N \g_@@_inrow_bool |
| 1253 |
|
| 1254 |
\box_new:N \l_@@_cell_box |
| 1255 |
\skip_new:N \l_@@_left_skip |
| 1256 |
\skip_new:N \l_@@_right_skip |
| 1257 |
\dim_new:N \g_@@_ht_dim |
| 1258 |
\dim_new:N \g_@@_dp_dim |
| 1259 |
\tl_new:N \g_@@_borders_tl |
| 1260 |
|
| 1261 |
\tl_new:N \l_@@_restore_tl |
| 1262 |
|
| 1263 |
\dim_new:N \l_@@_tablepadding_top_dim |
| 1264 |
\dim_new:N \l_@@_tablepadding_bottom_dim |
| 1265 |
\tl_new:N \l_@@_color_tl |
| 1266 |
\tl_new:N \l_@@_bgcolor_tl |
| 1267 |
|
| 1268 |
\seq_new:N \l_@@_classes_at_start_seq |
| 1269 |
|
| 1270 |
\cs_new_protected:Nn \@@_array_init: { |
| 1271 |
\tl_set:Nx \l_@@_restore_tl { |
| 1272 |
\bool_if:NTF \g_@@_inrow_bool { |
| 1273 |
\exp_not:n {\bool_gset_true:N \g_@@_inrow_bool} |
| 1274 |
}{ |
| 1275 |
\exp_not:n {\bool_gset_false:N \g_@@_inrow_bool} |
| 1276 |
} |
| 1277 |
\exp_not:n { \int_gset:Nn \g_@@_row_int } |
| 1278 |
{ \int_use:N \g_@@_row_int } |
| 1279 |
\exp_not:n { \int_gset:Nn \g_@@_col_int } |
| 1280 |
{ \int_use:N \g_@@_col_int } |
| 1281 |
\exp_not:n { \dim_gset:Nn \g_@@_ht_dim } |
| 1282 |
{ \dim_use:N \g_@@_ht_dim } |
| 1283 |
\exp_not:n { \dim_gset:Nn \g_@@_dp_dim } |
| 1284 |
{ \dim_use:N \g_@@_dp_dim } |
| 1285 |
\exp_not:n { \tl_gset:Nn \g_@@_borders_tl } |
| 1286 |
{ \exp_not:V \g_@@_borders_tl } |
| 1287 |
} |
| 1288 |
% \end{macrocode} |
| 1289 |
% |
| 1290 |
% Unset all previous active classes, and set current ones as active. |
| 1291 |
% |
| 1292 |
% \begin{macrocode} |
| 1293 |
\seq_map_inline:Nn \l_@@_classes_at_start_seq { |
| 1294 |
\bool_set_false:c { l_@@_active_classes_##1_bool } |
| 1295 |
} |
| 1296 |
\seq_set_eq:NN \l_@@_classes_at_start_seq \l_@@_classes_seq |
| 1297 |
\seq_map_inline:Nn \l_@@_classes_at_start_seq { |
| 1298 |
\bool_set_true:c { l_@@_active_classes_##1_bool } |
| 1299 |
} |
| 1300 |
% \end{macrocode} |
| 1301 |
% |
| 1302 |
% To count rows and columns. |
| 1303 |
% |
| 1304 |
% \begin{macrocode} |
| 1305 |
\int_gzero:N \g_@@_row_int |
| 1306 |
\bool_gset_false:N \g_@@_inrow_bool |
| 1307 |
\tl_gclear:N \g_@@_borders_tl |
| 1308 |
\cs_set_eq:NN \@@_orig_tab@readpreamble:n \tab@readpreamble |
| 1309 |
\cs_set_eq:NN \tab@readpreamble \@@_readpreamble:n |
| 1310 |
% \end{macrocode} |
| 1311 |
% |
| 1312 |
% Zero \cs{col@sep} but remember its value for the default padding. |
| 1313 |
% |
| 1314 |
% \begin{macrocode} |
| 1315 |
\dim_set_eq:NN \l_@@_colsep_dim \col@sep |
| 1316 |
\dim_zero:N \col@sep |
| 1317 |
% \end{macrocode} |
| 1318 |
% |
| 1319 |
% Also ignore \cs{*extrasep} dimensions that are not part of cellprop |
| 1320 |
% interface and should be replaced by CSS equivalents. |
| 1321 |
% |
| 1322 |
% \begin{macrocode} |
| 1323 |
\dim_zero:N \tab@extrasep |
| 1324 |
\group_begin: |
| 1325 |
\@@_recall_properties:n {table} |
| 1326 |
\dim_gset:Nn \g_tmpa_dim { \@@_get_property:n {padding-top} } |
| 1327 |
\dim_gset:Nn \g_tmpb_dim { \@@_get_property:n {padding-bottom} } |
| 1328 |
\@@_update_colors: |
| 1329 |
\tl_gset_eq:NN \g_tmpa_tl \l_@@_color_tl |
| 1330 |
\tl_gset_eq:NN \g_tmpb_tl \l_@@_bgcolor_tl |
| 1331 |
\group_end: |
| 1332 |
\dim_set_eq:NN \l_@@_tablepadding_top_dim \g_tmpa_dim |
| 1333 |
\dim_set_eq:NN \l_@@_tablepadding_bottom_dim \g_tmpb_dim |
| 1334 |
\tl_set_eq:NN \l_@@_color_tl \g_tmpa_tl |
| 1335 |
\tl_set_eq:NN \l_@@_bgcolor_tl \g_tmpb_tl |
| 1336 |
\dim_set:Nn \l_@@_strut_ht_dim { \box_ht:N \@arstrutbox } |
| 1337 |
\dim_set:Nn \l_@@_strut_dp_dim { \box_dp:N \@arstrutbox } |
| 1338 |
\box_clear:N \@arstrutbox |
| 1339 |
} |
| 1340 |
|
| 1341 |
\cs_set_nopar:Nn \@@_array_startcontent: { |
| 1342 |
\hlx{s[\l_@@_tablepadding_top_dim]} |
| 1343 |
} |
| 1344 |
|
| 1345 |
\cs_new_protected_nopar:Nn \@@_maybe_startrow: { |
| 1346 |
\bool_if:NF \g_@@_inrow_bool { |
| 1347 |
\bool_gset_true:N \g_@@_inrow_bool |
| 1348 |
\int_gincr:N \g_@@_row_int |
| 1349 |
\int_gset_eq:NN \g_@@_col_int \c_one_int |
| 1350 |
\dim_gzero:N \g_@@_ht_dim |
| 1351 |
\dim_gzero:N \g_@@_dp_dim |
| 1352 |
} |
| 1353 |
} |
| 1354 |
|
| 1355 |
\cs_new_protected_nopar:Nn \@@_maybe_endrow: { |
| 1356 |
\bool_if:NT \g_@@_inrow_bool { |
| 1357 |
\@@_every_cell_end: |
| 1358 |
\bool_gset_false:N \g_@@_inrow_bool |
| 1359 |
} |
| 1360 |
} |
| 1361 |
|
| 1362 |
\cs_new_protected_nopar:Nn \@@_every_cell_end: { |
| 1363 |
\int_gincr:N \g_@@_col_int |
| 1364 |
} |
| 1365 |
|
| 1366 |
\cs_set_protected_nopar:Nn \@@_readpreamble:n { |
| 1367 |
\cs_set_eq:NN \tab@readpreamble \@@_orig_tab@readpreamble:n |
| 1368 |
% \end{macrocode} |
| 1369 |
% |
| 1370 |
% \cs{tab@multicol} is inserted at the beginning of a each row, and by |
| 1371 |
% \cs{multicolumn} after its \cs{omit}. We use it to ensure that the row is |
| 1372 |
% initialized correctly however it starts (normally or with a |
| 1373 |
% \cs{multicolumn}). |
| 1374 |
% |
| 1375 |
% \cs{tab@tabtext} is inserted at the end of every cell but the last one, so |
| 1376 |
% we should ensure that its effect is applied at the end of the row; |
| 1377 |
% \cs{@@_maybe_endrow} will take care of that. |
| 1378 |
% |
| 1379 |
% \begin{macrocode} |
| 1380 |
\tl_put_left:Nn \tab@multicol {\@@_maybe_startrow:} |
| 1381 |
\tl_put_left:Nn \tab@tabtext {\@@_every_cell_end:} |
| 1382 |
\tab@readpreamble{#1} |
| 1383 |
\exp_args:Nx \tab@preamble |
| 1384 |
{ \the\tab@preamble \exp_not:N\@@_maybe_endrow: } |
| 1385 |
} |
| 1386 |
% \end{macrocode} |
| 1387 |
% |
| 1388 |
% The color inheritance is handled with \cs{l_@@_inherit_color_tl}, |
| 1389 |
% \cs{l_@@_color_tl} and \cs{l_@@_bgcolor_tl}. The role of |
| 1390 |
% \cs{@@_update_color:Nn} is to set the inherit fallback to the already |
| 1391 |
% existing value of \verb|#1| then set \verb|#1| to the CSS value, which can be |
| 1392 |
% the inherit variable. |
| 1393 |
% |
| 1394 |
% \begin{macrocode} |
| 1395 |
\cs_new_protected_nopar:Nn \@@_update_color:Nn { |
| 1396 |
\@@_get_property:nN {#2} \l_tmpa_tl |
| 1397 |
\exp_args:NV \tl_if_eq:NNF \l_tmpa_tl \c_@@_inherit_color_tl { |
| 1398 |
\tl_set_eq:NN #1 \l_tmpa_tl |
| 1399 |
} |
| 1400 |
} |
| 1401 |
|
| 1402 |
\cs_new_protected_nopar:Nn \@@_update_colors: { |
| 1403 |
\@@_update_color:Nn \l_@@_color_tl {color} |
| 1404 |
\@@_update_color:Nn \l_@@_bgcolor_tl {background-color} |
| 1405 |
} |
| 1406 |
% \end{macrocode} |
| 1407 |
% |
| 1408 |
% Patch the \cs{@array}, \cs{LT@array}, \cs{@mkpream}, \cs{endarray} and |
| 1409 |
% \cs{endlongtable} commands, so that we can properly setup our line and column |
| 1410 |
% counting system. This is the most brittle part of \pkg{cellprops}, and subject |
| 1411 |
% to compatibility problems with other packages that patch those (\pkg{hyperref} |
| 1412 |
% in particular). |
| 1413 |
% |
| 1414 |
% \begin{macrocode} |
| 1415 |
\AtEndPreamble{% |
| 1416 |
\cs_set_eq:NN \@@_orig_array:w \@array |
| 1417 |
\cs_set_protected_nopar:Npn \@array[#1]#2 { |
| 1418 |
\@@_array_init: |
| 1419 |
\@@_orig_array:w [#1]{#2} |
| 1420 |
\@@_array_startcontent: |
| 1421 |
} |
| 1422 |
|
| 1423 |
\cs_set_eq:NN \@@_orig_LTmkpream:n \@mkpream |
| 1424 |
\cs_set_protected_nopar:Npn \@mkpream#1 { |
| 1425 |
\group_end: |
| 1426 |
\@@_array_init: |
| 1427 |
\group_begin: |
| 1428 |
\@@_orig_LTmkpream:n {#1} |
| 1429 |
} |
| 1430 |
|
| 1431 |
\cs_set_eq:NN \@@_orig_LTarray:w \LT@array |
| 1432 |
\cs_set_protected_nopar:Npn \LT@array [#1]#2 { |
| 1433 |
\@@_orig_LTarray:w [#1]{#2} |
| 1434 |
\@@_array_startcontent: |
| 1435 |
} |
| 1436 |
|
| 1437 |
\cs_new_nopar:Nn \@@_end_array:n { |
| 1438 |
\tl_if_empty:NF \g_@@_borders_tl { \\ } |
| 1439 |
\crcr |
| 1440 |
\hlx{s[\l_@@_tablepadding_bottom_dim]} |
| 1441 |
#1 |
| 1442 |
\tl_use:N \l_@@_restore_tl |
| 1443 |
} |
| 1444 |
|
| 1445 |
\cs_set_eq:NN \@@_orig_endarray: \endarray |
| 1446 |
\cs_set_nopar:Npn \endarray { |
| 1447 |
\@@_end_array:n { \@@_orig_endarray: } |
| 1448 |
} |
| 1449 |
\cs_set_eq:NN \endtabular \endarray |
| 1450 |
\cs_set_eq:cN {endtabular*} \endarray |
| 1451 |
|
| 1452 |
\cs_set_eq:NN \@@_orig_endLT: \endlongtable |
| 1453 |
\cs_set_nopar:Npn \endlongtable { |
| 1454 |
\@@_end_array:n { \@@_orig_endLT: } |
| 1455 |
} |
| 1456 |
|
| 1457 |
\cs_new_protected_nopar:Nn \@@_cr:n { |
| 1458 |
\@@_maybe_endrow: |
| 1459 |
\tl_if_empty:NF \g_@@_borders_tl { |
| 1460 |
\cr |
| 1461 |
\noalign{\nobreak} |
| 1462 |
\tl_use:N \g_@@_borders_tl |
| 1463 |
\tl_gclear:N \g_@@_borders_tl |
| 1464 |
} |
| 1465 |
\cr |
| 1466 |
\@@_fix_valign_end:n {#1} |
| 1467 |
\use_none:n |
| 1468 |
} |
| 1469 |
|
| 1470 |
\cs_set_protected_nopar:Npn \tab@tabcr #1#2 { \@@_cr:n {#2} } |
| 1471 |
\cs_set_protected_nopar:Npn \@xargarraycr #1 { \@@_cr:n {#1} } |
| 1472 |
\cs_set_protected_nopar:Npn \@yargarraycr #1 { \@@_cr:n {#1} } |
| 1473 |
\tl_if_exist:NT \LT@echunk { |
| 1474 |
\tl_put_left:Nn \LT@echunk { |
| 1475 |
\tl_if_empty:NF \g_@@_borders_tl { \\ } |
| 1476 |
} |
| 1477 |
} |
| 1478 |
|
| 1479 |
\cs_set_eq:NN \@@_orig_multicolumn:w \multicolumn |
| 1480 |
\cs_set:Npn \multicolumn#1#2#3 { |
| 1481 |
\@@_orig_multicolumn:w {#1}{#2}{#3} |
| 1482 |
\int_gadd:Nn \g_@@_col_int {#1} |
| 1483 |
\tl_gput_right:Nx \g_@@_borders_tl { |
| 1484 |
\prg_replicate:nn {#1 - 1} {\span\omit} |
| 1485 |
} |
| 1486 |
\ignorespaces |
| 1487 |
} |
| 1488 |
|
| 1489 |
} |
| 1490 |
|
| 1491 |
\cs_new_nopar:Nn \@@_fix_valign_end:n { |
| 1492 |
\noalign{ |
| 1493 |
\dim_set:Nn \l_tmpa_dim {#1} |
| 1494 |
\skip_vertical:n {\l_tmpa_dim} |
| 1495 |
\exp_args:NV \tl_if_eq:nnTF \tab@hlstate {b} { |
| 1496 |
\dim_gadd:Nn \tab@endheight { \g_@@_dp_dim + \l_tmpa_dim } |
| 1497 |
}{ |
| 1498 |
\int_compare:nNnT \g_@@_row_int = \c_one_int { |
| 1499 |
\dim_gadd:Nn \tab@endheight { \g_@@_ht_dim } |
| 1500 |
} |
| 1501 |
} |
| 1502 |
} |
| 1503 |
} |
| 1504 |
% \end{macrocode} |
| 1505 |
% |
| 1506 |
% Reset \cs{firsthline} and \cs{lasthline} to \cs{hline} because the version |
| 1507 |
% from \pkg{array} which might be loaded already will mess up the spacing and is |
| 1508 |
% unneeded anyway. |
| 1509 |
% |
| 1510 |
% \begin{macrocode} |
| 1511 |
\cs_set_eq:NN \firsthline \hline |
| 1512 |
\cs_set_eq:NN \lasthline \hline |
| 1513 |
|
| 1514 |
\colpush{tabular} |
| 1515 |
|
| 1516 |
\coldef n{\tabcoltype{ |
| 1517 |
\@@_begincell:n{} |
| 1518 |
}{ |
| 1519 |
\@@_endcell: |
| 1520 |
}} |
| 1521 |
\coldef l{\tabcoltype{ |
| 1522 |
\@@_begincell:n |
| 1523 |
{\@@_use_setter:nn {text-align} {left}} |
| 1524 |
}{ |
| 1525 |
\@@_endcell: |
| 1526 |
}} |
| 1527 |
\coldef c{\tabcoltype{ |
| 1528 |
\@@_begincell:n |
| 1529 |
{\@@_use_setter:nn {text-align} {center}} |
| 1530 |
}{ |
| 1531 |
\@@_endcell: |
| 1532 |
}} |
| 1533 |
\coldef r{\tabcoltype{ |
| 1534 |
\@@_begincell:n |
| 1535 |
{\@@_use_setter:nn {text-align} {right}} |
| 1536 |
}{ |
| 1537 |
\@@_endcell: |
| 1538 |
}} |
| 1539 |
\coldef M#1{\@@_MTcol:nn {math}{#1}} |
| 1540 |
\coldef T#1{\@@_MTcol:nn {text}{#1}} |
| 1541 |
\cs_new_protected_nopar:Nn \@@_MTcol:nn { |
| 1542 |
% TODO: error if align not l, c, or r |
| 1543 |
\exp_args:Nx \tabcoltype { |
| 1544 |
\exp_not:N \@@_begincell:n { |
| 1545 |
\exp_not:n {\@@_use_setter:nn {math-mode} {#1} } |
| 1546 |
\exp_not:n {\@@_use_setter:nn {text-align}} { |
| 1547 |
\str_case:nn {#2} { |
| 1548 |
{l} {left} |
| 1549 |
{c} {center} |
| 1550 |
{r} {right} |
| 1551 |
} |
| 1552 |
} |
| 1553 |
} |
| 1554 |
}{ |
| 1555 |
\@@_endcell: |
| 1556 |
} |
| 1557 |
} |
| 1558 |
|
| 1559 |
\coldef p#1{\tabcoltype{ |
| 1560 |
\@@_begin_par_cell:nn \vtop {#1} |
| 1561 |
}{ |
| 1562 |
\@@_end_par_cell:n {} |
| 1563 |
}} |
| 1564 |
\coldef m#1{\tabcoltype{ |
| 1565 |
\@@_begin_par_cell:nn {\c_math_toggle_token\vcenter} {#1} |
| 1566 |
}{ |
| 1567 |
\@@_end_par_cell:n{\c_math_toggle_token} |
| 1568 |
}} |
| 1569 |
\coldef b#1{\tabcoltype{ |
| 1570 |
\@@_begin_par_cell:nn \vbox {#1} |
| 1571 |
}{ |
| 1572 |
\@@_end_par_cell:n {} |
| 1573 |
}} |
| 1574 |
|
| 1575 |
|
| 1576 |
\colpop |
| 1577 |
|
| 1578 |
\cs_new_protected_nopar:Nn \@@_begincell:n { |
| 1579 |
\@@_begin_raw_cell:n { |
| 1580 |
#1 |
| 1581 |
\hbox_set:Nw \l_@@_cell_box |
| 1582 |
\str_case_e:nnF {\@@_get_property:n {math-mode}} { |
| 1583 |
{ text } { \tab@btext } |
| 1584 |
{ math } { \tab@bmaths } |
| 1585 |
}{% any other treated as |auto| |
| 1586 |
\tab@bgroup |
| 1587 |
} |
| 1588 |
} |
| 1589 |
} |
| 1590 |
|
| 1591 |
\cs_new_protected_nopar:Nn \@@_endcell: { |
| 1592 |
\str_case_e:nnF {\@@_get_property:n {math-mode}} { |
| 1593 |
{ text } { \tab@etext } |
| 1594 |
{ math } { \tab@emaths } |
| 1595 |
}{% any other treated as |auto| |
| 1596 |
\tab@egroup |
| 1597 |
} |
| 1598 |
\hbox_set_end: |
| 1599 |
\@@_end_raw_cell: |
| 1600 |
} |
| 1601 |
|
| 1602 |
\cs_new_protected_nopar:Nn \@@_begin_par_cell:nn { |
| 1603 |
\savenotes |
| 1604 |
\@@_begin_raw_cell:n{ |
| 1605 |
\hbox_set:Nw \l_@@_cell_box |
| 1606 |
#1 |
| 1607 |
\bgroup |
| 1608 |
\hsize#2\relax |
| 1609 |
\@arrayparboxrestore |
| 1610 |
\global\@minipagetrue |
| 1611 |
\everypar{ |
| 1612 |
\global\@minipagefalse |
| 1613 |
\everypar{} |
| 1614 |
} |
| 1615 |
\@@_recall_properties:n {p} |
| 1616 |
} |
| 1617 |
} |
| 1618 |
\cs_new_protected_nopar:Nn \@@_end_par_cell:n { |
| 1619 |
\ifhmode\@maybe@unskip\par\fi |
| 1620 |
\unskip |
| 1621 |
\egroup |
| 1622 |
#1 |
| 1623 |
\hbox_set_end: |
| 1624 |
\@@_end_raw_cell: |
| 1625 |
\spewnotes |
| 1626 |
} |
| 1627 |
|
| 1628 |
\cs_new_protected_nopar:Nn \@@_begin_raw_cell:n { |
| 1629 |
\group_begin: |
| 1630 |
\@@_recall_properties:n {tr} |
| 1631 |
\@@_update_colors: |
| 1632 |
\@@_recall_properties:n {td} |
| 1633 |
\@@_update_colors: |
| 1634 |
% Additional init code |
| 1635 |
#1 |
| 1636 |
% Install the cell color |
| 1637 |
\@@_update_colors: |
| 1638 |
\tl_use:N \l_@@_color_tl |
| 1639 |
} |
| 1640 |
|
| 1641 |
\cs_new_protected_nopar:Nn \@@_make_solid_hborder:nnn { |
| 1642 |
\group_begin: |
| 1643 |
\hbox_set_to_wd:Nnn \l_tmpa_box {1pt} { |
| 1644 |
\hss |
| 1645 |
\hbox:n { |
| 1646 |
#3 % install color |
| 1647 |
\vrule height~\dim_eval:n{#1+#2} |
| 1648 |
~depth~-\dim_eval:n{#2} |
| 1649 |
~width~3pt |
| 1650 |
} |
| 1651 |
\hss |
| 1652 |
} |
| 1653 |
\box_set_ht:Nn \l_tmpa_box { \c_zero_dim } |
| 1654 |
\box_set_dp:Nn \l_tmpa_box { \c_zero_dim } |
| 1655 |
\kern 1pt |
| 1656 |
\box_use:N \l_tmpa_box |
| 1657 |
\xleaders |
| 1658 |
\box_use:N \l_tmpa_box |
| 1659 |
\skip_horizontal:n {-4pt~plus~1fil} |
| 1660 |
\box_use:N \l_tmpa_box |
| 1661 |
\kern 1pt |
| 1662 |
\skip_horizontal:n {0pt~plus~-1fil} |
| 1663 |
\group_end: |
| 1664 |
} |
| 1665 |
\cs_new_protected_nopar:Nn \@@_make_solid_vborder:nnn { |
| 1666 |
\group_begin: |
| 1667 |
\hbox_set_to_wd:Nnn \l_tmpa_box {0pt} { |
| 1668 |
\hbox:n { |
| 1669 |
#3 % install color |
| 1670 |
\vrule height~\dim_eval:n{#2}~width~\dim_eval:n{#1} |
| 1671 |
} |
| 1672 |
\hss |
| 1673 |
} |
| 1674 |
\box_set_ht:Nn \l_tmpa_box { \c_zero_dim } |
| 1675 |
\box_set_dp:Nn \l_tmpa_box { \c_zero_dim } |
| 1676 |
\box_use:N \l_tmpa_box |
| 1677 |
\group_end: |
| 1678 |
} |
| 1679 |
\clist_map_inline:nn { |
| 1680 |
dotted, dashed, solid, double, |
| 1681 |
groove, ridge, inset, outset |
| 1682 |
}{ |
| 1683 |
\cs_set_eq:cN {@@_make_#1_hborder:nnn} \@@_make_solid_hborder:nnn |
| 1684 |
\cs_set_eq:cN {@@_make_#1_vborder:nnn} \@@_make_solid_vborder:nnn |
| 1685 |
} |
| 1686 |
|
| 1687 |
\dim_new:N \l_@@_border_width_dim |
| 1688 |
\str_new:N \l_@@_border_style_str |
| 1689 |
\tl_new:N \l_@@_border_color_tl |
| 1690 |
\cs_new_protected_nopar:Nn \@@_get_border_info:n { |
| 1691 |
\dim_set:Nn \l_@@_border_width_dim {\@@_get_property:n {border-#1-width}} |
| 1692 |
\@@_get_property:nN {border-#1-style} \l_tmpa_tl |
| 1693 |
\exp_args:NNV \str_set:Nn \l_@@_border_style_str \l_tmpa_tl |
| 1694 |
\tl_clear:N \l_@@_border_color_tl |
| 1695 |
\cs_if_exist:cTF {@@_make_\l_@@_border_style_str _hborder:nnn} { |
| 1696 |
\@@_update_color:Nn \l_@@_border_color_tl {border-#1-color} |
| 1697 |
}{ |
| 1698 |
\dim_zero:N \l_@@_border_width_dim |
| 1699 |
} |
| 1700 |
} |
| 1701 |
|
| 1702 |
\cs_new_protected_nopar:Npn \@@_make_hborder:nnnn #1 { |
| 1703 |
\use:c { @@_make_#1_hborder:nnn } |
| 1704 |
} |
| 1705 |
\cs_new_protected_nopar:Npn \@@_make_vborder:nnnn #1 { |
| 1706 |
\use:c { @@_make_#1_vborder:nnn } |
| 1707 |
} |
| 1708 |
|
| 1709 |
\cs_new_protected_nopar:Nn \@@_end_raw_cell: { |
| 1710 |
% Here \l_@@_cell_box must contain the contents of the cell |
| 1711 |
% |
| 1712 |
% Prepare the borders token list |
| 1713 |
\int_compare:nNnT \g_@@_col_int = 1 { |
| 1714 |
\tl_gclear:N \g_@@_borders_tl |
| 1715 |
} |
| 1716 |
\tl_gput_right:Nx \g_@@_borders_tl { |
| 1717 |
\tl_if_empty:NF \g_@@_borders_tl { \exp_not:n {&} } |
| 1718 |
\exp_not:n { \omit \kern \c_zero_dim } |
| 1719 |
} |
| 1720 |
% Handle min-height, min-depth and vertical-align |
| 1721 |
% wrong values are treated as |baseline|. |
| 1722 |
\box_set_ht:Nn \l_@@_cell_box { |
| 1723 |
\dim_max:nn |
| 1724 |
{\box_ht:N \l_@@_cell_box} |
| 1725 |
{\@@_get_property:n {min-height}} |
| 1726 |
} |
| 1727 |
\box_set_dp:Nn \l_@@_cell_box { |
| 1728 |
\dim_max:nn |
| 1729 |
{\box_dp:N \l_@@_cell_box} |
| 1730 |
{\@@_get_property:n {min-depth}} |
| 1731 |
} |
| 1732 |
\str_case_e:nn {\@@_get_property:n {vertical-align}} { |
| 1733 |
{ top } { |
| 1734 |
\hbox_set:Nn \l_@@_cell_box { |
| 1735 |
\vbox_top:n { |
| 1736 |
\kern 0pt\relax |
| 1737 |
\box_use_drop:N \l_@@_cell_box |
| 1738 |
} |
| 1739 |
} |
| 1740 |
} |
| 1741 |
{ bottom } { |
| 1742 |
\hbox_set:Nn \l_@@_cell_box { |
| 1743 |
\vbox:n { |
| 1744 |
\box_use_drop:N \l_@@_cell_box |
| 1745 |
\kern 0pt\relax |
| 1746 |
} |
| 1747 |
} |
| 1748 |
} |
| 1749 |
{ middle } { |
| 1750 |
\hbox_set:Nn \l_@@_cell_box { |
| 1751 |
\dim_set:Nn \l_tmpa_dim { |
| 1752 |
(\box_dp:N \l_@@_cell_box |
| 1753 |
- \box_ht:N \l_@@_cell_box |
| 1754 |
+ 1ex) / 2 |
| 1755 |
} |
| 1756 |
\raisebox{\l_tmpa_dim}{\box_use_drop:N \l_@@_cell_box} |
| 1757 |
} |
| 1758 |
} |
| 1759 |
} |
| 1760 |
% Handle padding-top and border-top |
| 1761 |
\@@_get_border_info:n {top} |
| 1762 |
\box_set_ht:Nn \l_@@_cell_box { |
| 1763 |
\box_ht:N \l_@@_cell_box |
| 1764 |
+ (\@@_get_property:n {padding-top}) |
| 1765 |
+ \l_@@_border_width_dim |
| 1766 |
} |
| 1767 |
\dim_compare:nNnT \l_@@_border_width_dim > \c_zero_dim { |
| 1768 |
\tl_gput_right:Nx \g_@@_borders_tl { |
| 1769 |
\exp_not:N \@@_make_hborder:nnnn |
| 1770 |
{ \exp_not:V \l_@@_border_style_str } |
| 1771 |
{ \dim_use:N \l_@@_border_width_dim } |
| 1772 |
{ |
| 1773 |
\exp_not:n { \g_@@_dp_dim + \g_@@_ht_dim - } |
| 1774 |
\dim_use:N \l_@@_border_width_dim |
| 1775 |
} |
| 1776 |
{ \exp_not:V \l_@@_border_color_tl } |
| 1777 |
} |
| 1778 |
} |
| 1779 |
% Handle padding-bottom and border-bottom |
| 1780 |
\@@_get_border_info:n {bottom} |
| 1781 |
\box_set_dp:Nn \l_@@_cell_box { |
| 1782 |
\box_dp:N \l_@@_cell_box |
| 1783 |
+ (\@@_get_property:n {padding-bottom}) |
| 1784 |
+ \l_@@_border_width_dim |
| 1785 |
} |
| 1786 |
\dim_compare:nNnT \l_@@_border_width_dim > \c_zero_dim { |
| 1787 |
\tl_gput_right:Nx \g_@@_borders_tl { |
| 1788 |
\exp_not:N \@@_make_hborder:nnnn |
| 1789 |
{ \exp_not:V \l_@@_border_style_str } |
| 1790 |
{ \dim_use:N \l_@@_border_width_dim } |
| 1791 |
{ \exp_not:n { 0pt } } |
| 1792 |
{ \exp_not:V \l_@@_border_color_tl } |
| 1793 |
} |
| 1794 |
} |
| 1795 |
% To fix vertical alignment later |
| 1796 |
\dim_gset:Nn \g_@@_ht_dim { |
| 1797 |
\dim_max:nn |
| 1798 |
{\g_@@_ht_dim} |
| 1799 |
{\box_ht:N \l_@@_cell_box} |
| 1800 |
} |
| 1801 |
\dim_gset:Nn \g_@@_dp_dim { |
| 1802 |
\dim_max:nn |
| 1803 |
{\g_@@_dp_dim} |
| 1804 |
{\box_dp:N \l_@@_cell_box} |
| 1805 |
} |
| 1806 |
% Handle padding-left and border-left |
| 1807 |
\@@_get_border_info:n {left} |
| 1808 |
\skip_set:Nn \l_@@_left_skip |
| 1809 |
{\@@_get_property:n {padding-left} + \l_@@_border_width_dim} |
| 1810 |
\dim_compare:nNnT \l_@@_border_width_dim > \c_zero_dim { |
| 1811 |
\tl_gput_right:Nx \g_@@_borders_tl { |
| 1812 |
\exp_not:N \@@_make_vborder:nnnn |
| 1813 |
{ \exp_not:V \l_@@_border_style_str } |
| 1814 |
{ \dim_use:N \l_@@_border_width_dim } |
| 1815 |
{ \exp_not:n { \g_@@_dp_dim + \g_@@_ht_dim } } |
| 1816 |
{ \exp_not:V \l_@@_border_color_tl } |
| 1817 |
} |
| 1818 |
} |
| 1819 |
\tl_gput_right:Nx \g_@@_borders_tl { |
| 1820 |
\exp_not:n { |
| 1821 |
\skip_horizontal:n {0pt~plus~1fil} |
| 1822 |
\kern \c_zero_dim |
| 1823 |
} |
| 1824 |
} |
| 1825 |
\@@_get_border_info:n {right} |
| 1826 |
\skip_set:Nn \l_@@_right_skip |
| 1827 |
{\@@_get_property:n {padding-right} + \l_@@_border_width_dim} |
| 1828 |
\dim_compare:nNnT \l_@@_border_width_dim > \c_zero_dim { |
| 1829 |
\tl_gput_right:Nx \g_@@_borders_tl { |
| 1830 |
\exp_not:N \skip_horizontal:n |
| 1831 |
{ - \dim_use:N \l_@@_border_width_dim } |
| 1832 |
\exp_not:N \@@_make_vborder:nnnn |
| 1833 |
{ \exp_not:V \l_@@_border_style_str } |
| 1834 |
{ \dim_use:N \l_@@_border_width_dim } |
| 1835 |
{ \exp_not:n { \g_@@_dp_dim + \g_@@_ht_dim } } |
| 1836 |
{ \exp_not:V \l_@@_border_color_tl } |
| 1837 |
\exp_not:N \skip_horizontal:n |
| 1838 |
{ \dim_use:N \l_@@_border_width_dim } |
| 1839 |
\exp_not:n { \kern \c_zero_dim } |
| 1840 |
} |
| 1841 |
} |
| 1842 |
% Handle hpadding and halign |
| 1843 |
\skip_set:Nn \l_tmpa_skip { |
| 1844 |
\dim_max:nn |
| 1845 |
{0pt} |
| 1846 |
{ (\@@_get_property:n {min-width}) |
| 1847 |
- \box_wd:N \l_@@_cell_box } |
| 1848 |
} |
| 1849 |
\skip_add:Nn \l_tmpa_skip { |
| 1850 |
1sp plus 1fil |
| 1851 |
} |
| 1852 |
\str_case_e:nnF {\@@_get_property:n {text-align}} { |
| 1853 |
{ right } { |
| 1854 |
\skip_add:Nn \l_@@_left_skip { \l_tmpa_skip } |
| 1855 |
} |
| 1856 |
{ center } { |
| 1857 |
\skip_add:Nn \l_@@_left_skip { \l_tmpa_skip / 2 } |
| 1858 |
\skip_add:Nn \l_@@_right_skip { \l_tmpa_skip / 2 } |
| 1859 |
} |
| 1860 |
}{% any other treated as |left| |
| 1861 |
\skip_add:Nn \l_@@_right_skip { \l_tmpa_skip } |
| 1862 |
} |
| 1863 |
\kern\c_zero_dim |
| 1864 |
\tl_if_empty:NF \l_@@_bgcolor_tl { |
| 1865 |
\group_begin: |
| 1866 |
% Paint a background with leaders |
| 1867 |
\tl_use:N \l_@@_bgcolor_tl % install the color |
| 1868 |
\skip_set:Nn \l_tmpa_skip { |
| 1869 |
\l_@@_left_skip |
| 1870 |
+ \box_wd:N \l_@@_cell_box |
| 1871 |
+ \l_@@_right_skip |
| 1872 |
} |
| 1873 |
\leaders |
| 1874 |
\vrule |
| 1875 |
\skip_horizontal:N \l_tmpa_skip |
| 1876 |
\skip_horizontal:n {-\l_tmpa_skip} |
| 1877 |
\group_end: |
| 1878 |
} |
| 1879 |
\skip_horizontal:N \l_@@_left_skip |
| 1880 |
\box_use_drop:N \l_@@_cell_box |
| 1881 |
\skip_horizontal:N \l_@@_right_skip |
| 1882 |
\kern\c_zero_dim |
| 1883 |
\group_end: |
| 1884 |
} |
| 1885 |
% \end{macrocode} |
| 1886 |
% |
| 1887 |
% \begin{macrocode} |
| 1888 |
%</package> |
| 1889 |
% \end{macrocode} |
| 1890 |
% |
| 1891 |
% \end{implementation} |