How can I export whatever I like to an HTML file, without Mathematica ensuring that it conforms to any standard? In other words, how can I get Mathematica simply to assign an .html suffix to a string I'm exporting?

  • 3
    $\begingroup$ Something like Export["name.html", "exported string", "String"]? $\endgroup$ – Carl Woll Sep 4 '17 at 23:20
  • $\begingroup$ That works. Thanks! I've now also found Export["name.txt", "exported string"]; RenameFile["name.txt", "name.html"]. $\endgroup$ – user51827 Sep 4 '17 at 23:26
  • $\begingroup$ Further investigation has shown that using Export followed by RenameFile is better, because unlike the Export as "String" method it retains the line feeds. $\endgroup$ – user51827 Sep 4 '17 at 23:47
  • $\begingroup$ Presumably you would just use "Text" instead of "String" then. $\endgroup$ – Carl Woll Sep 4 '17 at 23:57
  • 1
    $\begingroup$ Just a general comment, "String" is a byte-based format, so generally in my experience "Text" has a few fewer surprises, as @CarlWoll pointed out. One case where "Text" can be worse than "String" is in performance, as it does some degree of conversion I believe. $\endgroup$ – b3m2a1 Sep 5 '17 at 3:31

Your Answer

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