Message Boards Message Boards

0
|
4509 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Best way to create a web page using Mathematica?

Posted 10 years ago
I'm interested in using Mathematica to generate HTML to define a web site. I can do the simple stuff using a notebook and saving it as HTML. I would appreciate any pointers as to how to work effectively. And I would especially appreciate knowing if there is a source of appropriate style sheets.
Best regards,
David
POSTED BY: David Keith
5 Replies
Few have that sort of courage.  That's why I stopped there ;-) 
POSTED BY: David Reiss
Posted 10 years ago
Ahh. I'm not sure I have the courage for that.  I spent a little time looking at HTML.  Got into the CSS MMA generated and fixed up what needed fixing. MMA going to html and cdf is quite nice!
POSTED BY: David Keith
It seems that the code that generates the CSS from stylesheets is deeply embedded within the internal Mathematica code for HTML export.  I went a few levels deep to try to see where it was but couldn't quite track it down. 

Once you've done an Export as HTML (so that the appropriate packges have been automatically loaded) you can take a look at the functions in the System`Convert`HTMLDump`  context.
?System`Convert`HTMLDump`*

Reverse engineering starts from there I suspect....
POSTED BY: David Reiss
Posted 10 years ago
Thanks very much, David. This is working pretty well. There are some discrepancies between what I see in the notebook and what results from the HTML, but they are very close. I looked into the CSS -- it looks like I could solve many discrepancies, and also make adjustments, by working with the code in both the HTML output and in the CSS. Do you have any idea how to get at the settings Mathematica uses to produce HTML from a given style sheet?
Best,
David
POSTED BY: David Keith
It all depends on how complex you want to go.  First off, the way to programatically save a notebook (or expression) as HTML is to use

Export["file.html", <<a notebook or a notebook object or an expression>>]

I have found that it takes some experimentation to decide what the right stylesheet elements to modify to get the effects that I want.

When the HTML is created, a CSS is also created based on the stylesheet that it used.  I have found that it takes some experimentation to figure out how to get the formatting that I want.  But getting this right is a good part of the work, though the defaults work pretty well for general use.

One useful trick is to create a template of an HTML page that you want....  eg, borders and other surrounding elements -- then you import as text the HTML generated by Export, extract  the portions that you want to embed in the template and then, using string manipulation techniques, insert it into the template. (One aslo can use String manipulation techniques to modify the resulting HTML -- for example to get rid of the Mathematica branding at the bottom of the page.)  This is the approach that I took (if I remember correctly) with this old blog of mine:

http://scientificarts.com/worklife/wlfwblog/index.html

B
y the way, that WorkLife application is something that I give away for free these days...  it's an old horse but it still works fine. 
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract