5
$\begingroup$

I need to customize some HTML tags when exporting a Mathematica notebook to HTML. I have to use the File ► Save As… FrontEnd token and not Export for some other reasons. So, to make a basic example, this is something that works fine:

Export["test.html", EvaluationNotebook[], "HTML", 
 "ConversionRules" -> {"ItemNumbered" -> {"<li>", "</li>"}, 
   "Text" -> {"<p class=\"mytext\">", "</p>"}}]

Now, I have seen that at FrontEnd level there is an option named ConversionOptions that includes "ExportOptions", that again includes "ConversionRules". So I'm trying to set such option, by means of the Option Inspector or by SetOptions, so to have the following

    ConversionOptions->{"ExportOptions"->{
 "HTML" -> {"ConversionRules" -> {"ItemNumbered" -> {"<li>", "</li>"}, "Text" -> {"<p class=\"mytext\">", "</p>"}}, 
    "GraphicsOutput"->"PNG", "MathOutput" -> "PNG", "ConvertClosed" -> False, "ConvertReverseClosed" -> 
    False, "ConvertLinkedNotebooks" -> False, "Content" -> False, 
    "CSSInclude" -> True, "CSSRadio" -> False}}}

Unfortunately using File ► Save As… does nothing of what I added into the ConversionOptions. Where I have to set my own export options for HTML?

$\endgroup$

1 Answer 1

5
$\begingroup$

Finally, after many attempts, I had the answer: the ConversionOptions have to be assigned to "XHTML" and not to "HTML". Indeed, this works:

ConversionOptions->{
  "ExportOptions"->{"XHTML" -> {"ConversionRules" -> {"ItemNumbered" -> 
            {"<li>", "</li>"}, "Text" -> {"<p class=\"mytext\">", "</p>"}}, 
            "GraphicsOutput"->"PNG", "MathOutput" -> "PNG",
            "ConvertClosed" -> False, "ConvertReverseClosed" -> False, 
            "ConvertLinkedNotebooks" -> False, "Content" -> False, 
            "CSSInclude" -> True, "CSSRadio" -> False}}}

This is very funny, documentation and all examples (really few, has to be said) set "HTML" ConversionRules when using it inside Export, but if you need to set it at FrontEnd level you have to assign it to "XHTML". However, at last it works!

$\endgroup$
1
  • 2
    $\begingroup$ Daily fun with MMA :) please consider reporting this to WRI. $\endgroup$
    – Kuba
    Jan 5, 2016 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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