Re: HTMLSave and Heading
- To: mathgroup at smc.vnet.net
- Subject: [mg34352] Re: [mg34207] HTMLSave and Heading
- From: Dale Horton <daleh at wolfram.com>
- Date: Thu, 16 May 2002 05:08:37 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
At 04:16 AM 5/9/2002, Alexandre Costa wrote: >Dear Group >I am trying to make some html pages using the HTMLSave function. >For example, I have these set of cells: >Cell 1: >Cell["Title", "Title"] >Cell 2: >Cell["\<\ >Basic equations >More text... >.......\ >\>", "Section1"] > >Cell 3: >Cell[BoxData["\n"], "NumberedEquation"] > >Cell 4: >Cell[BoxData["\n"], "NumberedEquation"] > >The prototype for "Section1" is given by: > >Cell[StyleData["Section1"], > PageWidth->PaperWidth, > CellFrame->{{0, 0}, {0.25, 0}}, > ShowGroupOpenCloseIcon->True, > CellMargins->{{5, 30}, {5, 5}}, > CellGroupingRules->{"SectionGrouping", 40}, > PageBreakBelow->False, > CellFrameLabels->{{Cell[ > TextData[ { > CounterBox[ "Section1"], ". "}]], None}, { > None, None}}, > InputAutoReplacements->{"TeX"->StyleBox[ > RowBox[ {"T", > AdjustmentBox[ > "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, > BoxBaselineShift -> 0.5], "X"}]], > "LaTeX"->StyleBox[ > RowBox[ {"L", > StyleBox[ > AdjustmentBox[ > "A", BoxMargins -> {{-0.36, -0.1}, {0, -0}}, > BoxBaselineShift -> -0.2], FontSize -> > Smaller], "T", > AdjustmentBox[ > "E", BoxMargins -> {{-0.075, -0.085}, {0, 0}}, > BoxBaselineShift -> 0.5], "X"}]], > "mma"->"Mathematica", "Mma"->"Mathematica", > "MMA"->"Mathematica"}, > CounterIncrements->"Section1", > CounterAssignments->{{"Section2", 0}, {"Section3", 0}, { > "Equation", 0}, {"Definition", 0}, {"Theorem", 0}, { > "Example", 0}}, > FontFamily->"Helvetica", > FontSize->14, > FontWeight->"Bold"] > >I have 3 simple questions: > >First: I want the automatic numbered "1" be in the same line of the >string "Basic Equations". >I.e. : > 1. Basic Equations > More text... > ... > >I have 2 simple questions regarding the HTML conversion: >Second: - I want to convert Cell 2 to HTML in such way that I keep the >same typesetting shown on the mathematica frontend. How can it be done? >Third: - How can I have the correct numbered equations for Cells 3 and 4 > after convert >them to HTML ? > >Any clue about any of these questions, are very welcome. > Cheers, > > Alexandre Costa The 1st and 3rd questions are along the same lines, but have slightly different solutions. Question 1 is "How do I show an automatic counter in a text-like cell?" Question 3 is "How do I show an automatic counter in a input-like (i.e. StandardForm) cell?" Because different mechanisms are used for the 2 kinds of cells, the solution is slightly different. First, get the notebook as a NotebookObject or Notebook expression. A simple way to do this is to extract the NotebookObject out of the list of open nbs. In[1]:= nb=Notebooks[][[2]] For input-like cells the default counter value is used when generating GIFs. We need a way to tell the fe to change the default for the counter. In[2]:= setnumeq[num_] := SetOptions[$FrontEnd, CounterAssignments->{{"NumberedEquation",num}}] Then, we can use "MarkupRules" to specify what to wrap around each cell. For text-like cells, we insert the number. For input-like cells, we reset the counter at each cell. Note, :> is used to make the counter increment each time the rule is used (-> will only increment the first time it's used). Finally, we reset the default counters so that the numbering is correct in the fe. In[3]:= section1counter=1; numeqcounter=0; Export["file.html",nb, ConversionOptions->{"MarkupRules"->{ "Section1":>{"<h2>"<>ToString[section1counter++]<>"."</h2>"}, "NumberedEquation":>{setnumeq[numeqcounter++];"<p>", "</p>"} }}]; SetOptions[$FrontEnd, CounterAssignments->{}] For Question 2, there are several ways to represent typesetting in HTML. This is done through the "MathOutput" ConversionOption. The default is "GIF" which uses graphics. If you want text in your HTML, you can try InputForm and DisplayForm. But since HTML is very limited in it's typesetting, these may not be what you want. There is also "MathML", which uses an XML syntax to represent typesetting. MathML is gaining acceptance as the standard for representing math on the web and support for it is growing rapidly. -Dale