lvjr / tabularray

Typeset tabulars and arrays with LaTeX3
https://ctan.org/pkg/tabularray
247 stars 22 forks source link

tex4ht support #327

Open blaueente opened 1 year ago

blaueente commented 1 year ago

tabularray should have tex4ht support, in order to enable conversion to html

Example from documentation:

\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}

\begin{tblr}{|l|[dotted]|[2pt]c|r|[solid]|[dashed]|}
\hline
One & Two & Three \\
\hline\hline[dotted]\hline
Four & Five & Six \\
\hline[dashed]\hline[1pt]
Seven & Eight & Nine \\
\hline
\end{tblr}

\end{document}

Result:

2 Rows 2 Columns 2 Rows 2 Columns 2-2 2-3 3-1 3-2 3-3 3-4 3-5 _ __ _ _____

One Two Three Four Five Six Seven Eight Nine _ __ ___


<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='tblr.css' rel='stylesheet' type='text/css' /> 
<meta content='tblr.tex' name='src' /> 
</head><body>
<!-- l. 17 --><p class='noindent'>    2
  Rows       2
          Columns          2
                          Rows
                            2
                         Columns                                     
          2-2   2-3

   3-1    3-2   3-3   3-4      3-5
                                     _____________________________________
        ______________
_____________________________________
_____________________________________
</p><!-- l. 28 --><p class='noindent'> One     Two   Three        _                
 Four     Five     Six
        _                
 Seven   Eight   Nine
        _                _______________________
_______________________
______________________________
_______________________
</p>

</body> 
</html>

Expected: 2022-11-12_12-08

lvjr commented 1 year ago

I think this is a feature request for tex4ht project. And I guess this is the correct place: https://puszcza.gnu.org.ua/bugs/?group=tex4ht

u-fischer commented 1 year ago

I don't agree that this is a task only for tex4ht. The hooks needed for tex4ht are quite similar to the hooks needed for tagging, see https://github.com/lvjr/tabularray/issues/27.

lvjr commented 1 year ago

I thought tex4ht worked like pandoc. Now I know I was wrong.

I have not yet decided how many hooks should be provided by tabularray.

@u-fischer and @michal-h21: You could leave your comments in issue #197.

michal-h21 commented 1 year ago

I've just added support for Tabularray to TeX4ht sources. I was able to support most of features, except for complicated lines and text property for vline.

lvjr commented 1 year ago

I decide to reopen this issue to record experiments with tex4ht here.

lvjr commented 1 year ago

@michal-h21 I have tried to improve tex4ht support with public hooks and varaibles based on your code in tex4ht and your comment in issue #197. Please see the latest trial/tabularray.sty file and trial/tex4ht folder in this repository.

I haven't handled the variables for cell alignment and cell widths yet, since they are a little complicated. By the way, I have also fixed a bug that all <tr> tags had the same id atrribute.