> Is it possible to use asciimath for both inline/displayed
> mathematics on the same page/with the same configuration with
> different delimiters? If not, I'd like to propose this as a feature.
AsciiMath notation doesn't have a way to indicate display math as
opposed to in-line math. The assumption is, I assume, that you will
use regular HTML formatting to separate and center displayed
equations. There is a variable (displaystyle) that controls how
AsciiMath handles things like limits on sums and so on, but it is a
global value, not something that you can readily change on an equation-
by-equation basis. MathJax has a configuration option that controls
the displaystyle variable, but again, that is global.
On the other hand, it is not too hard to write an extension that does
what I think you are asking for. Here is an example file that does it:
<!DOCTYPE html>
<html>
<head>
<title>Add Inline/Display Control to AsciiMath</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
asciimath2jax: {delimiters: [['`','`'],['``','``']]},
AsciiMath: {displaystyle: false}
});
MathJax.Hub.Register.LoadHook("[MathJax]/extensions/
asciimath2jax.js",function () {
var AM = MathJax.Extension.asciimath2jax,
CREATEPATTERNS = AM.createPatterns;
AM.createPatterns = function () {
var result = CREATEPATTERNS.call(this);
this.match['``'].mode = ";mode=display";
return result;
};
});
MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready",function () {
var AM = MathJax.InputJax.AsciiMath;
AM.postfilterHooks.Add(function (data) {
if (data.script.type.match(/;mode=display/))
{data.math.root.display = "block"}
return data;
});
});
</script>
<script type="text/javascript" src="../MathJax/MathJax.js?
config=AM_HTMLorMML"></script>
</head>
<body>
<INPUT TYPE="BUTTON" onclick="debug();" VALUE="Debug">
<p>Inline AsciiMath: `sum_{n=1}^10 n^2 = 55`</p>
<p>Display AsciiMath: ``sum_{n=1}^10 n^2 = 55``</p>
</body>
</html>
This makes `...` do inline math and ``...`` do displayed math. The
asciimath2jax extension has to be configured to include the double-
tick delimiters, and it createPatterns routine is modified to add a
parameter to the double-tick that tells asciimath2jax to mark the math
with double-ticks as display math. Then you add a postfilter to the
AsciiMath input jax that checks for display math elements and adds the
display="block" attribute to the root math node of the math that
AsciiMath generates. That's pretty much it.
Hope that does what you need.
Davide