Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
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

1 Answer 1

up vote 5 down vote accepted

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]
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.