3
$\begingroup$

In the following link you can find the following about ConversionRules when exporting to HTML:

specifies mappings from Mathematica cell styles to HTML elements, including both inline and block-level versions of the markup

Lets define the following temporary function with the following conversion rules:

TempFunction[expr_] := ExportString[expr, "HTML",
    "FullDocument" -> False,
    "ConversionRules" -> {
        "InlineMath" -> {
            {"<inline>", Convert`TeX`BoxesToTeX[#] &, "</inline>"},
            {"<block>", Convert`TeX`BoxesToTeX[#] &, "</block>"}
        },
        "Text" -> {
            {"<inlineText>", "</inlineText>"},
            {"<blockText>", "</BlockText>"}
        },
        "" -> {"", ""}
    }
]

As the quote says, I have specified both the inline and block versions of the mapping. Now lets use it to see if they work as intended.

CASE 1:

Here we use a single block cell.

TempFunction[
    Cell[BoxData[FormBox[RowBox[{"x", "=", "y"}], TraditionalForm]], "InlineMath"]
]

The output is:

<block>x=y</block>

CASE 2:

Here we use an inline cell.

TempFunction[
    Cell[TextData[{"Let ", 
    Cell[BoxData[
    FormBox[RowBox[{"x", " ", "=", " ", SuperscriptBox["y", "2"]}],
    TraditionalForm]], "InlineMath", FormatType -> "TraditionalForm"], "."}], "Text"]
]
<blockText>Let <inline>x = y^2</inline>.</BlockText>

CASE 3:

TempFunction[
    Cell[TextData[{"Let ", 
    Cell[BoxData[
    FormBox[RowBox[{"x", " ", "=", " ", "y"}], TraditionalForm]], 
    "InlineMath", FormatType -> "TraditionalForm"], "."}], "Text"]
]
<blockText>Let <inline><em>x</em><em> </em><em>=</em><em> </em><em>y</em></inline>.</BlockText>

I was expecting this:

<blockText>Let <inline>x = y</inline>.</BlockText>

Is this a bug? What style is being surrounded by the tag em? Case 1 and Case 2 make sense, but Case 3 has me scratching my head. Can someone explain this behavior?

$\endgroup$
9
  • $\begingroup$ Weird behaviour, that just by adding a superscriptbox in a rowbox, single letters are emphasized $\endgroup$
    – Rojo
    May 27, 2012 at 5:51
  • $\begingroup$ @Rojo methink it is the other way around ... $\endgroup$ May 27, 2012 at 6:14
  • $\begingroup$ @belisarius and Rojo, Since you guys are checking this out, try replacing TraditionalForm for TextForm in CASE 3. What do you guys think? $\endgroup$
    – jmlopez
    May 27, 2012 at 6:23
  • $\begingroup$ @belisarious, I was being ironic, I meant the opposite, couldn't you tell? $\endgroup$
    – Rojo
    May 27, 2012 at 6:46
  • $\begingroup$ @jmlopez, you mean that the problem gets fixed? Same happens with StandardForm. Probably has to do with TraditionalForm having SingleLetterItalics set to true. Can't test much right now $\endgroup$
    – Rojo
    May 27, 2012 at 6:49

1 Answer 1

3
$\begingroup$

You should be able to turn this off globally for your current kernel session by using a variant of the solution posted by Albert Retey to an earlier question of mine:

SetOptions[$FrontEnd, 
 FormatType :> (Style[TraditionalForm[##],SingleLetterItalics -> False] &)]

You might also want to set the same for Graphics, depending on what you are exporting.

SetOptions[Graphics,
 FormatType :> (Style[TraditionalForm[##],SingleLetterItalics -> False] &)]
$\endgroup$
1
  • 1
    $\begingroup$ This didn't seem to work, at least with the example that I showed. Still, +1, for showing me that you can modify different parts of a style. For now, the best answer I have is set DefaultInlineFormatType->TextForm, in the notebook options. That way, when you write inline cells, in this case, my InlineMath cell, then it will have the TextForm as default and the HTML converter will not emphasize the letters. $\endgroup$
    – jmlopez
    May 28, 2012 at 17:21

Your Answer

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

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