# Problem with exporting nested Rows/Columns to HTML

I will show the problem on the following MWE:

Export["test.html",
Column[{ Row[{"test", "1"}]  }],
"HTML",
"CSS" -> None]

$RecursionLimit::reclim: Recursion depth of 1024 exceeded. >> General::stop: Further output of$RecursionLimit::reclim will be suppressed during this
calculation. >>


Single Row[{"test", "1"}] without Column produces no error. Also let's assume I can't use Grid.

-
Looks like a bug to me. I have found exporting to HTML to be rather buggy in a lot of cases. –  m_goldberg Nov 4 '13 at 13:02
@m_goldberg Ah :( it is rather frustrating because Grid[{{}}] instead of Row[{}] behaves in different way. –  Kuba Nov 4 '13 at 13:05

Updated

Using

ToBoxes@Column[{Row[{"test", "1"}]}]


we get

TagBox[GridBox[{{TemplateBox[{"\"test\"", "\"1\""}, "RowDefault"]}}, <<omitted output>>


That TemplateBox is strange because Row should have translated into RowBox. Let us force it:

kubaExport[x_] := ExportString[ ToBoxes@x
/. TemplateBox[a_, "RowDefault"] :> RowBox[a] // RawBoxes,
"HTML", "FullDocument" -> False];

kubaExport[Column[{Row[{"test", "1"}]}]]


yields what you need.

<table class='Output'>
<tr style='vertical-align: baseline;'>
<td style='text-align: left;'><span>test1</span></td>
</tr>
</table>


First try

Export with HTML is not happy with anything but cells. Ergo, wrap your objects in a cell. The following code works.

ExportString[Cell@ToBoxes@Column[{Row[{"test", "1"}]}], "HTML", "CSS" -> None]

-
You might notice that Export to HTML produces an empty page. That happens because the export functionality is (somewhat) broken for 2D content such as scripts, grids, etc. But that is another question. –  Hector Nov 4 '13 at 14:47
Yes, I was just about to ask :) So the only difference is that there is not error, but still there is no html? I could use Quiet :) –  Kuba Nov 4 '13 at 14:50
@Kuba: Nope, that is not the only difference. Without the wrapping, Mathematica seems to try (and fails at) creating the 2D content with HTML tables. –  Hector Nov 4 '13 at 14:56
I'm glad you didn't delete the answer permanently :) I will test this as soon as I get home. :) –  Kuba Nov 4 '13 at 16:06