The aloha editor inserts either a <br>
tag or a <p>
tag when you press enter, or you paste something that has newlines in it. Now this was fine, until I wanted to use the {aligned}
environment in MathJax, that would have a format like:
\[\begin{aligned}
2x+3 &= 7 & 2x+3-3 &= 7-3 \\
2x &= 4 & \frac{2x}2 &= \frac42 \\
x &= 2
\end{aligned}\]
where \[...\]
are delimiters indicating that MathJax should process the contents. Aloha editor wraps each line in a <p>
tag that separates the delimiters so MathJax is unable to process them.
So my question is, is there a way to paste or enter text into aloha without splitting it into multiple text nodes? Alternatively, is there a way to make MathJax read delimiters across tags?
Edit: I'm asking because I don't want to do something like
var math="";
_.each($("p:contains(\[)"),function(startEl){
math= $(startEl).html();
var startIndex = $(startEl).index();
var endIndex = $(startEl).parent().find("p:contains(\])").first().index();
$(startEl).siblings().slice(startIndex, endIndex).each(function(index){
math+=$(this).html();
});
$(startEl).siblings().slice(startIndex, endIndex).remove();
$(startEl).replaceWith("<p>"+math+"</p>");
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
});
to take the TeX inside the separate <p>
s and put it into one <p>
because it doesn't feel robust at all