3
$\begingroup$

When exporting a notebook to HTML, the notebook's cells render as images, but the text is often squished. For example, this notebook:

enter image description here

... renders as

enter image description here

If I manually line-break the code, the picture looks ok. However, I'd prefer an automated solution.

Is there a magic incantation to give to Export to have it break the lines before converting them to snapshots?

Thanks.

(There are links related to converting cells to text instead of images: 1, 2, 3. I don't mind the images, if only they didn't squish the text.)

Update 2: The problem was solved by resetting Mathematica to "factory defaults" by holding Alt+Shift while starting the program. More info Note: this wipes out everything in ~/Library/Mathematica and /Library/Mathematica, including any customizations to your init.m file in ~/Library/Mathematica/Kernel/init.m.

Update: After some experimentation, it seems the line-breaking depends on the size of the notebook's window at the time it was exported to HTML.

To reproduce the problem reliably, try this example, which produces a sequence of longer and longer output lines:

Column[Table[Series[Exp[x], {x, 0, i}], {i, 20}]]

Notebook:

enter image description here

HTML output:

enter image description here

The situation can be helped by outputting to SVG instead of the default GIF, like this:

t = "SVG";
Export["foo.html", EvaluationNotebook[], "Graphics3DOutput" -> t, "GraphicsOutput" -> t, "ManipulateOutput" -> t, "MathOutput" -> t]

This produces a beautiful HTML page like this:

enter image description here

$\endgroup$
  • $\begingroup$ I can't replicate the behavior on Windows with 11.1. The notebook exports as expected. What version are you using? Do you have any idea why your first line was condensed, but the last rendered normally? Are there other lines like that? $\endgroup$ – Stitch Jun 7 '17 at 19:09
  • $\begingroup$ @Stitch, my version is "11.1.0 for Mac OS X x86 (64-bit) (March 16, 2017)". To replicate the problem, try executing this in a notebook then "save as" to HTML: Column[Table[Series[Exp[x], {x, 0, i}], {i, 20}]] $\endgroup$ – ConvexMartian Jun 7 '17 at 21:30
  • $\begingroup$ It seems to be idiosyncratic to Mac or to 11.1.0. The second example works equally fine on Windows and Linux 11.1.1. Try 11.1.1 and if it persists and other Mac users have the same, you might report it as a bug. It seems like you also found a solution based on that HTML link I provided in your second question. In fact, "MathOutput" is the only option that might affect your examples. $\endgroup$ – Stitch Jun 7 '17 at 22:04
  • $\begingroup$ I upgraded to 11.1.1 and the problem persisted, so I reported the problem to Wolfram. $\endgroup$ – ConvexMartian Jun 7 '17 at 22:47
  • $\begingroup$ WRI got back to me. The problem was solved by resetting Mathematica to "factory defaults" by holding Alt+Shift while starting the program (on a Mac). More info. Note: this wipes out everything in ~/Library/Mathematica and /Library/Mathematica, including any customizations to your init.m file in ~/Library/Mathematica/Kernel/init.m. $\endgroup$ – ConvexMartian Jun 8 '17 at 18:06
2
$\begingroup$

The problem was solved by resetting Mathematica to "factory defaults" by holding Alt+Shift while starting the program (on a Mac). For more details see this link at Wolfram Support. Note: this wipes out everything in ~/Library/Mathematica/ and /Library/Mathematica/, including any customizations to your init.m file in ~/Library/Mathematica/Kernel/init.m.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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