Commit 0f3a1461 by noraiz-anwar Committed by GitHub

Merge pull request #13551 from noraiz-anwar/na/mathjax-fix

Fix mathjax rendering
parents 07caef95 34ab38d7
...@@ -384,10 +384,9 @@ ...@@ -384,10 +384,9 @@
} else if (RE_DISPLAYMATH.test(htmlString)) { } else if (RE_DISPLAYMATH.test(htmlString)) {
htmlString = htmlString.replace(RE_DISPLAYMATH, function($0, $1, $2, $3) { htmlString = htmlString.replace(RE_DISPLAYMATH, function($0, $1, $2, $3) {
/* /*
bug fix, ordering is off corrected mathjax rendering in preview
*/ */
processedHtmlString = processor('$$' + $2 + '$$', 'display') + processedHtmlString; processedHtmlString += $1 + processor('$$' + $2 + '$$', 'display');
processedHtmlString = $1 + processedHtmlString;
return $3; return $3;
}); });
} else { } else {
......
...@@ -758,3 +758,11 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin): ...@@ -758,3 +758,11 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin):
""" """
self.wait_for_element_visibility(".wmd-preview > *", "WMD preview pane has contents", timeout=10) self.wait_for_element_visibility(".wmd-preview > *", "WMD preview pane has contents", timeout=10)
return self.q(css=".wmd-preview").html[0] return self.q(css=".wmd-preview").html[0]
def get_new_post_preview_text(self):
"""
Get the rendered preview of the contents of the Discussions new post editor
Waits for content to appear, as the preview is triggered on debounced/delayed onchange
"""
self.wait_for_element_visibility(".wmd-preview > div", "WMD preview pane has contents", timeout=10)
return self.q(css=".wmd-preview").text[0]
...@@ -959,6 +959,22 @@ class DiscussionEditorPreviewTest(UniqueCourseTest): ...@@ -959,6 +959,22 @@ class DiscussionEditorPreviewTest(UniqueCourseTest):
"</ul>" "</ul>"
)) ))
def test_mathjax_rendering_in_order(self):
"""
Tests that mathjax is rendered in proper order.
When user types mathjax expressions into discussion editor, it should render in the proper
order.
"""
self.page.set_new_post_editor_value(
'Text line 1 \n'
'$$e[n]=d_1$$ \n'
'Text line 2 \n'
'$$e[n]=d_2$$'
)
self.assertEqual(self.page.get_new_post_preview_text(), 'Text line 1\nText line 2')
@attr(shard=2) @attr(shard=2)
class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMixin): class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMixin):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment