Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
in Q2A Core by


I asked this question about 3 years ago :) http://question2answer.org/qa/39275

based on Kai's answer it's enought to add MathJax.Hub.Queue(['Typeset', MathJax.Hub, e]);  to https://github.com/q2a/question2answer/blob/dev/qa-content/qa-question.js#L76

qa_ajax_post('answer', params,

there I have added

                var answTxt = lines.slice(3).join("\n"); 
                if(answTxt.indexOf('^')!=-1 && answTxt.indexOf('$$')==-1 && answTxt.indexOf('\\(')==-1) { 
                    e.innerHTML = answTxt; 
                else { 
                    e.innerHTML = answTxt; 
                    if(answTxt.indexOf('$$')!=-1 || answTxt.indexOf('\(')!=-1 ) { 
                        // insert mathjax-config for linebreak option 
                        $('head').append('<script type="text/x-mathjax-config"> MathJax.Hub.Config({ "HTML-CSS": { scale:100, linebreaks: { automatic: true } }, SVG: { linebreaks: { automatic: true } }, displayAlign: "left" }); </script>'); 
                        var mjaxURL = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML&locale=de'; // ,Safe.js 
                        // as soon mathjax is loaded 
                        $.getScript(mjaxURL, function() { 
                            // mathjax loaded, call it on the comment which is e 
                            MathJax.Hub.Queue(['Typeset', MathJax.Hub, e]); 

This works fine but when you click on "comment" or "add comment" all the page will be reloaded and then rendered by mathjax. I want just the comment will be reloaded to show math.

Is there any way?

1 Answer

+2 votes
selected by
Yes. I have.
Thank you. It works very well. but why do you use 'PrettyPrint' after mathjax call?(
MathJax.Hub.Queue(['Typeset', MathJax.Hub, e]);//arjun
 is it necessary? I think it causes some problems when adding comments.
If it causes problem, you may remove it. I added it to use prettyprint for code formatting.
I have created a plugin with basic MatjJax settings. It should render it on comment too.
you can check it at  https://github.com/varuninorbit/question2answer-mathjax-plugin