     html += "<script data-js-code>#{jsCode}</script>" if jsCode
     return html
 
+  fixPandocMathExpression: (htmlContent)->
+    return htmlContent if !@usePandocParser
+    $ = cheerio.load htmlContent
+    window.ch = $
+    $('.math').each (index, elem)=>
+      $math = $(elem)
+      displayMode = $math.hasClass('display')
+      if displayMode
+        tagStart = @mathBlockDelimiters[0][0]
+        tagEnd = @mathBlockDelimiters[0][1]
+      else
+        tagStart = @mathInlineDelimiters[0][0]
+        tagEnd = @mathInlineDelimiters[0][1]
+      $math.html(tagStart + $math.text().trim() + tagEnd)
+
+      if displayMode and $math.next()?[0]?.name == 'br'
+        $math.next().remove()
+
+    return $.html()
+
   ##
   # {Function} callback (htmlContent)
   getHTMLContent: ({isForPrint, offline, useRelativeImagePath, phantomjsType, isForPrince, embedLocalImages}, callback)->

          </script>
          <script type=\"text/javascript\" async src=\"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML\"></script>
          "
      else
        mathStyle = ''



      # replace code chunks inside htmlContent
      htmlContent = @insertCodeChunksResult htmlContent
      htmlContent = @fixPandocMathExpression htmlContent

      if mathRenderingOption == 'MathJax' or @usePandocParser
        inline = atom.config.get('markdown-preview-enhanced.indicatorForMathRenderingInline')
        block = atom.config.get('markdown-preview-enhanced.indicatorForMathRenderingBlock')
        mathJaxProcessEnvironments = atom.config.get('markdown-preview-enhanced.mathJaxProcessEnvironments')
