Bug 11761 fixed: Exception in rendering mathml: xstring(0,0.2,'<mi>x</mi><mn>3</mn>') 24/8824/5
Calixte DENIZET [Mon, 27 Aug 2012 12:38:41 +0000 (14:38 +0200)]
Change-Id: Idd3bf1156b8e0cae34bbda8ac7921b29d8b1250d

scilab/CHANGES_5.4.X
scilab/modules/console/src/java/org/scilab/modules/console/utils/ScilabSpecialTextUtilities.java

index 1e9b96b..b70ed5d 100644 (file)
@@ -152,6 +152,8 @@ Bug Fixes
 * Bug #11760 fixed - Exceptions were thrown when trying to display invalid
                      latex or mathml.
 
+* Bug #11761 fixed - There was an exception in rendering MathML.
+
 * Bug #11764 fixed - The 'ispc' m2sci help page was not updated regarding the
                      MSDOS removal.
 
index c6264f7..e7baefc 100644 (file)
@@ -98,14 +98,14 @@ public final class ScilabSpecialTextUtilities {
         if (!loadedLaTeX) {
             if (loadJLM == null) {
                 loadJLM = new Thread(new Runnable() {
-                    /* Create a thread in the background to avoid a lag in the loading of jar */
-                    public void run() {
-                        LoadClassPath.loadOnUse("graphics_latex_textrendering");
-                        LaTeXCompiler.compilePartial("", 0);
-                        loadedLaTeX = true;
-                        loadJLM = null;
-                    }
-                });
+                        /* Create a thread in the background to avoid a lag in the loading of jar */
+                        public void run() {
+                            LoadClassPath.loadOnUse("graphics_latex_textrendering");
+                            LaTeXCompiler.compilePartial("", 0);
+                            loadedLaTeX = true;
+                            loadJLM = null;
+                        }
+                    });
                 loadJLM.setPriority(Thread.MIN_PRIORITY);
                 loadJLM.start();
             }
@@ -218,6 +218,10 @@ public final class ScilabSpecialTextUtilities {
             LayoutContextImpl parameters = new LayoutContextImpl(LayoutContextImpl.getDefaultLayoutContext());
             parameters.setParameter(Parameter.MATHSIZE, fontSize);
             parameters.setParameter(Parameter.MATHCOLOR, fontColor);
+            if (!str.startsWith("<mathml>")) {
+                str = "<mathml>" + str + "</mathml>";
+            }
+
             Document doc = null;
             try {
                 doc = MathMLParserSupport.parseString(str);