tabularray icon indicating copy to clipboard operation
tabularray copied to clipboard

Provide public hooks and variables

Open lvjr opened this issue 3 years ago • 12 comments

We need to provide some hooks via hook library:

tabularray/begin
tabularray/end
tabularray/trial/before
tabularray/trial/after
tabularray/table/before
tabularray/table/after
tabularray/row/before
tabularray/row/after
tabularray/cell/before
tabularray/cell/after

See #27, #29, #146, #159, #179.

lvjr avatar Feb 09 '22 02:02 lvjr

Good idea! Is there any reason to put them in a library? Why not provide them by default?

marvlg avatar Feb 12 '22 09:02 marvlg

Hooks make the package run slower. And hooks can not work in TeX Live 2020 on Overleaf.

lvjr avatar Feb 13 '22 03:02 lvjr

For the HTML conversion with TeX4ht, I need to be able to detect features like colspan, rowspan, cell alignment, colors and borders. It seems that most of these information (except for borders, probably?) are available in the \__tblr_build_cell_content:NN macro, where I can use them for inline CSS for each table cell.

The one problem that I have found so far is how to detect a cell that shouldn't be displayed. In HTML, when you use <td collspan="2">, you shouldn't include next <td>, because it would be spurious. The same is true for rowspan, the <td> that is bellow the one that uses rowspan, shouldn't be used. So we need to detect somehow that the current cell is hidden. It shouldn't be hard to do that on the TeX4ht side, but I wonder if it already isn't available in tabularray and I just missed it. It is also possible that tagged PDF will need such functionality as well.

For example:

\documentclass{article}
\usepackage{tabularray}
\begin{document}

\begin{tblr}{|c|c|c|c|c|}
\hline
\SetCell[r=2]{c} 2 Rows
& \SetCell[c=2]{c} 2 Columns
& & \SetCell[r=2,c=2]{c} 2 Rows 2 Columns & \\
\hline
& 2-2 & 2-3 & & \\
\hline
3-1 & 3-2 & 3-3 & 3-4 & 3-5 \\
\hline
\end{tblr}
\end{document}

michal-h21 avatar Nov 30 '22 11:11 michal-h21

I need to solve issue #179 first before starting to handle this issue. So hooks will not arrive soon.

lvjr avatar Nov 30 '22 14:11 lvjr

For the HTML conversion with TeX4ht, I need to be able to detect features like colspan, rowspan, cell alignment, colors and borders. It seems that most of these information (except for borders, probably?) are available in the \__tblr_build_cell_content:NN macro, where I can use them for inline CSS for each table cell.

Why not get cell colors and others at the time of their settings? When an user writes \cellcolor{blue} in tabular, tex4ht gets the style. Then when an user writes \SetCell{blue} in tabularray, tex4ht should be able to do the same job.

lvjr avatar Nov 30 '22 14:11 lvjr

In the above commit, I have added libraries hook and html into trial/tabularray.sty. All public hooks and variables are documented in https://github.com/lvjr/tabularray/wiki/HooksAndVariables

Now we can do some experiments with tagpdf, tex4ht and lwarp.

lvjr avatar Feb 11 '23 01:02 lvjr