Extension talk:Wiki2LaTeX/Development/w2lParser.php

Table support
I've transplanted the table parser from mediaWiki into doTableStuff and externalTableHelper, so the parser is now totally compatible with the wiki table markup supported by mediaWiki. (Except captions, that requires some extra LaTeX fiddeling, like putting the table inside a figure, or something.)

To coax LaTeX into making a nice table, some extra input is needed. Therefore, I added support for an extra attribute "latexfmt" to the table. The attribute as then passed on to LaTeX to tell how many rows there are, and which type of cells should be used for each row. An extra cell type Y is introduced for left-aligned text than can wrap. Example:

HTML-style tables can be supported by replacing &lt;table&gt;, &lt;tr&gt;, &lt;td&gt; etc. in processHtmlEntities, but the tables will normally look terrible because the latexfmt attribute is missing.

-Ole, Aug 22nd 2007.


 * "The attribute as then passed on to LaTeX to tell how many rows there are...", don't you mean "columns"? Could you post the tex script generated for this example so I can double check that what I'm seeing is correct? I don't get any vertical lines, unfortunately I wouldn't quite call it a "nice" table! Hoogs 11:03, 24 September 2007 (UTC)
 * The error was caused by a typo above at the latexfmt-attribute. Should work now as expected.--HG 11:40, 24 September 2007 (UTC)
 * I had already fixed that. I guess my point is that out of the box, this example isn't a particularly attractive table, or is it just me?  Here is the test wikitext:

and using these options on the "latex" page:

Documentclass: Article Leave NoInclude-blocks in main Article Process Templates and Parserfunctions Use "W2L Plain" template from this site

here is the latex script produced:

\newcolumntype{Y}{>{\raggedright\arraybackslash}X}\begin{tabularx}{\linewidth}{|Y|l|r|}\hline

\textbf{ header 1 } & \textbf{ header 2 } & \textbf{ header 3}\\ \hline

row 1, cell 1 &  row 1, cell 2  &  row 1, cell 3\\ \hline

row 2, cell 1 & row 2, cell 2 & row 2, cell 3\\ \hline \end{tabularx}

and the [[Media:W2L-TestTable01.pdf|pdf produced]]. I have no problems if this functionality needs a bit more work, I'm just wondering if we really believe that this is "nice", or if the translation could be a bit better. Hoogs 06:02, 25 September 2007 (UTC)
 * Well, I guess the template is outdated. You have to include the tabularx-package into the template-file, or you can use this one. The generated table should basically look like the Mediawiki-result, but with borders. I hope this helps.--HG 07:30, 25 September 2007 (UTC)