ExportString[Grid[{{a, b}}], "HTMLFragment"]
"<table><tbody> <tr><td>a</td><td>b</td></tr> </tbody></table>"
This is what I expect, but what if I want to convert Grid[{ {c[b, 1], 1} }]
and I want an expression with head c
to be exported with custom rule, like:
c[x_,y___] :> StringJoin["<div>",ToString[x], "</div>"]
So for
ExportString[Grid[{{c[d, 1], b}}], "HTMLFragment"]
I'd get:
"<table><tbody> <tr><td> <div>d</div> </td> <td> b </td></tr> </tbody></table>"
or for:
a[ Grid[{ {c[b, 1], 1} }], 1 ]
"<div> <table><tbody> <tr> <td> <div>b</div> </td> <td> 1 </td> </tr> </tbody></table> </div>"
Solution returning XMLElement
structure is ok too.
I know I can create a parser and convert everything from top to down but then I have to rewrite rules for things that could've been translated automatically.
Is there simpler approach?
Key words: Export HTML HTMLFragment conversion XML XMLElement tag tags
ExportString[expr /. rules, "HTMLFragment"]
? $\endgroup$a[ Grid[{ {a[b, 1], 1} }], 1 ]
. This should return div - table.../table - /div. $\endgroup$"XMLTransformationFunction"
but it works only for things that are already translated to some tags. $\endgroup$