Tom Lieber's Microblog

Apr 30, 2023

My workflow is nascent, but this is the snippet that allowed me to drop that last Mathematica notebook into my site template with no modifications:

Export["body.html", EvaluationNotebook[], "HTML",
 "CSS" -> None,
 "FullDocument" -> False,
 "GraphicsOutput" -> "PNG",
 "ConversionRules" -> {
   "Title" -> {"<h1>", "</h1>"},
   "Section" -> {"<h2>", "</h2>"},
   "Subsection" -> {"<h3>", "</h3>"},
   "Text" -> {"<p>", "</p>"},
   "Input" -> {"<pre>", "</pre>"},
   "Item" -> {"<li>", "</li>"}
   }]

I follow that up with cat head.html body.html tail.html > index.html.

By default, Mathematica turns all those cell types into <p> with classes like “Title” and “Section”, but once I switched to the semantic equivalents, they just worked.

I still haven’t figured out how I want to do margin notes, or how to wrap lists in <ol> or <ul>, or how to embed text versions of all the inputs that it renders as PNG—but in this case I felt that perfect was the enemy of good!