Fix EDU-702 In new recommendation latex text displays incorrectly
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Wed, 3 Aug 2016 15:53:25 +0000 (18:53 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Wed, 3 Aug 2016 15:58:55 +0000 (18:58 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java
python/educational-core/student/src/com/jetbrains/edu/learning/stepic/EduAdaptiveStepicConnector.java

index 4f11fdb8ff2b065614408a2fc33080d2aa1619bc..ca0d6ca9b7bc32fde12acfccb3f7559974a1c7da 100644 (file)
@@ -476,21 +476,26 @@ public class StudyUtils {
       return null;
     }
 
-    final String prefix = String.format(ourPrefix, EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
+    
     String text = task.getText();
     if (text != null && !text.isEmpty()) {
-      return prefix + text + ourPostfix;
+      return wrapTextToDisplayLatex(text);
     }
     if (taskDirectory != null) {
       final String taskTextFileHtml = getTaskTextFromTaskName(taskDirectory, EduNames.TASK_HTML);
-      if (taskTextFileHtml != null) return prefix + taskTextFileHtml + ourPostfix;
+      if (taskTextFileHtml != null) return wrapTextToDisplayLatex(taskTextFileHtml);
       
       final String taskTextFileMd = getTaskTextFromTaskName(taskDirectory, EduNames.TASK_MD);
-      if (taskTextFileMd != null) return prefix + convertToHtml(taskTextFileMd) + ourPostfix;      
+      if (taskTextFileMd != null) return wrapTextToDisplayLatex(convertToHtml(taskTextFileMd));      
     }
     return null;
   }
 
+  public static String wrapTextToDisplayLatex(String taskTextFileHtml) {
+    final String prefix = String.format(ourPrefix, EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
+    return prefix + taskTextFileHtml + ourPostfix;
+  }
+
   @Nullable
   private static String getTaskTextFromTaskName(@NotNull VirtualFile taskDirectory, @NotNull String taskTextFilename) {
     taskDirectory.refresh(false, true);
index 20d40e5b096d8a5e2789c19f547a46668c7cba4d..6ba3d2169a91b7007731ebb03547f864d2989967 100644 (file)
@@ -271,7 +271,7 @@ public class EduAdaptiveStepicConnector {
             }
             final StudyToolWindow window = StudyUtils.getStudyToolWindow(project);
             if (window != null) {
-              window.setTaskText(unsolvedTask.getText(), unsolvedTask.getTaskDir(project), project);
+              window.setTaskText(StudyUtils.wrapTextToDisplayLatex(unsolvedTask.getText()), unsolvedTask.getTaskDir(project), project);
             }
           }
           else {