14
$\begingroup$

This is a known issue for me with Mathematica. When I export a notebook to HTML, Mathematica loses some decorations such as Grid Frame lines (in grid and like objects).

For example, creating this small notebook:

Grid[{
  {Text@Style["Wolfram pages"]},
  {Hyperlink["http://www.wolfram.com"]},
  {Hyperlink["http://demonstrations.wolfram.com"]}
  }, Frame -> All
 ]

Then I do SAVE AS and select HTML. When I look at the HTML, the frame is lost:

enter image description here

Here is a link to a post of mine at Math group asking on this in march of last year (link)

I got one response, and I followed advice given in the response above, but nothing came out of it.

I thought I ask again, may be some experts here would have a simple solution or a trick to this.

I am thinking of using Mathematica notebook to save my URL's into instead of Microsoft word where I have them now, since I think I can organize them better with Grid and frames and such and it would look better, but if I can't get frames to show up, then there is no point of even trying. My other option would be to use Latex and generate HTML from Latex using Latex2html which I know pretty well.

I find it strange that such a basic thing does not work, given that what this page says http://reference.wolfram.com/mathematica/guide/CreatingWebPages.html

Mathematica supports industrial-strength automatic creation of 
full-featured web pages. 

Well, if Grid frames and Dividers and items like these do not show up in the final exported HTML, then I do not think I would call it a full-featured web pages? Or Am I missing something here?

I hope this is resolved in version 9, but I'd like to use Mathematica for this if it works.

note(1)

Thanks for all the responses. It seems editing the css will work ok for me now. It is not a big problem, since I keep the css commands in a small text file and just paste them each time I update my HTML.

One nice thing about using Mathematica for this, is that now I can automate some things, like counters for html links and such, as the final grid is computed with whatever variables in it. Here is a small example, where the html link number is a simple counter.

enter image description here

I can now move all my saved URL's (have 100's of them) from word to the notebook and use this method. I need small help on something, could not figure how to do: Any one knows how to align all rows below the first row to the LEFT? I wanted to keep the top row centered and all the rows below LEFT aligned. Should I make a new question for this part since it is not related to my main question? I tried, but Grid alignment of separate entries has always been like black magic to me, I read the help many times, and can't decipher the description at all.

thanks everyone for the help.

edit(2)

Please ignore my question above about Grid alignment. I gave up trying to figure how to use Alignment option to do this, and used the Item trick. This is much simpler.

So each row I want to align in the center, I just use Item on it, and since Item has it own Alignment option, then I can use that instead. Here is how it works now. I like it now, and I think this will work well for me. I am a happy camper now.

enter image description here

$\endgroup$
2
  • $\begingroup$ As immediately follows your excerpt: "Mathematica's unified symbolic architecture allows you to build up linked web page contents as symbolic expressions using the full power of the Mathematica system." I am sure you could do this if you wrote your own BoxForm to HTML code, but that is hardly convenient. +1 $\endgroup$
    – Mr.Wizard
    Jan 22, 2012 at 10:49
  • 1
    $\begingroup$ If you use Framed or GraphicsGrid you will see that Mathematica rasters the content of what is inside the frame. This points out to me that, probably, the omission of this capability was intentional. I'm absolutely no expert on css, but I think that you can get what you want by changing the css file (although, since there's no specific class defined, it would change all grids / html tables). I've quickly tried "table, th, td {border: 1px solid black;}" and I got something close to what you want. Have a look at w3schools.com/css/css_table.asp $\endgroup$
    – P. Fonseca
    Jan 22, 2012 at 11:42

2 Answers 2

8
$\begingroup$

Following my comment on your question, if you add

table
{
border-collapse:collapse;
}
table, td, th
{
border:1px solid black;
}

at the beginning of the css file, you will get:

enter image description here

$\endgroup$
7
$\begingroup$

P.Fonseca's answer will work fine as long as you don't mind editing the CSS file after export.

There might be another way using the ConversionRules options for stylesheets.

Something like:

mystyle = 
Notebook[{Cell[StyleData["GridBox"], 
 ConversionRules -> {"HTML" -> {{"<table border='1'>", 
      "</table>"}, {"<td>", "</td>"}}}]}];

I have not yet got it working as it should and you will probably still need the border-collapse:collapse; CSS setting on the table element. But this might point you in the direction of an automated solution.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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