3

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?

jmlopez
  • 6,470
  • 4
  • 28
  • 48
  • Weird behaviour, that just by adding a superscriptbox in a rowbox, single letters are emphasized – Rojo May 27 '12 at 05:51
  • @Rojo methink it is the other way around ... – Dr. belisarius May 27 '12 at 06:14
  • @belisarius and Rojo, Since you guys are checking this out, try replacing TraditionalForm for TextForm in CASE 3. What do you guys think? – jmlopez May 27 '12 at 06:23
  • @belisarious, I was being ironic, I meant the opposite, couldn't you tell? – Rojo May 27 '12 at 06:46
  • @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 – Rojo May 27 '12 at 06:49
  • @Rojo, The problem does get fixed. But I just don't know why or how. Yes, I also tried it with StandardForm but I ended up choosing the other. – jmlopez May 27 '12 at 07:04
  • @jmlopez, I have no clue why adding a SuperscripbBox in the RowBox could ever make such a difference. You want single letters to be emphasised or not? Perhaps you could test editing the style "TraditionalForm" in the stylesheet and setting SingleLetterItalics to False then? – Rojo May 27 '12 at 07:31
  • @Rojo, I think this might be due to how the HTML conversion works. If you change the second argument of ExportString from "HTML" to "TeX" then it works as I expected. In any case, I do not want the letters to be emphasized. For now the quick solution is to not to use TraditionalForm. – jmlopez May 27 '12 at 07:38
  • @Rojo Nope. It was "too late for tears" here :) – Dr. belisarius May 27 '12 at 17:11

1 Answers1

3

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] &)]
Verbeia
  • 34,233
  • 9
  • 109
  • 224
  • 1
    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. – jmlopez May 28 '12 at 17:21