asciimath / asciimathml

A new home for asciimathml
http://asciimath.org/
MIT License
957 stars 184 forks source link

Add support for displaying on separate line #49

Open yokto opened 8 years ago

yokto commented 8 years ago

Is there a shorthand way to display asciimath on a separate line like $$...$$ in latex. On this site http://www.wjagray.co.uk/maths/ASCIIMathTutorial.html it says that you only need an empty line above and below, but this doesn't seem to work.

drlippman commented 8 years ago

Short answer - no. AsciiMath doesn't attempt to handle layout issues in general - those are better handled by the surrounding HTML.

nickbower commented 3 years ago

Short answer - no. AsciiMath doesn't attempt to handle layout issues in general - those are better handled by the surrounding HTML.

No matter what we might think of where this is better handled, it is unfortunately academic for a user that must deal with long equations that will be clipped without an alternative. MathJax does not automatically reflow equations by breaking them, as you suggest they should. But it does accommodate manual breaks when issued say using Tex syntax instead of AsciiMath.

So question restated; why would AsciiMath at least not offer a similar line breaking support to help users in absence of any other solution?

Pretending such support could/should/might exist elsewhere has not shown to be that productive 4 years on...

davidfarmer commented 3 years ago

I have been thinking about similar things.

In LaTeX, is \int_2^5 2x \, dx inline or display? The answer depends on whether that expression falls between single or double dollar signs.

We have single backtick for inline AsciiMath. It could have been set up (not sure if this was suggested and rejected) to use double backtick for display AsciiMath.

As that does not seem to be an option, the old comment "handled by the surrounding HTML" means that you have to do something to set off that AsciiMath on its own line. Depending on how you prepare your source, a blank line before and after the backticks might do it. But probably that gives you a flush left displayed equation. And it does not address the multiline issue.

On Wed, 3 Mar 2021, nickbower wrote:

  Short answer - no. AsciiMath doesn't attempt to handle layout issues in general - those are better
  handled by the surrounding HTML.

No matter what we might think of where this is better handled, it is unfortunately academic for a user that must deal with long equations that will be clipped without an alternative. MathJax does not automatically reflow equations by breaking them, as you suggest they should. But it does accommodate manual breaks when issued say using Tex syntax instead of AsciiMath.

So question restated; why would AsciiMath at least not offer a similar line breaking support to help users in absence of any other solution?

Pretending such support could/should/might exist elsewhere has not shown to be that productive 4 years on...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, orunsubscribe.[AABTULCWU3C7T6WMFRY26JTTBYUBZA5CNFSM4B67S4PKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWS ZGOF4IZUKI.gif]

drlippman commented 3 years ago

If there was going to be a separate delimiter that invoked an equivalent of tex's display mode, that would probably need to be in Mathjax, not Asciimath. Asciimath just handles the generation of MathML.

dpvc commented 3 years ago

If you are using MathJax to manage the input and output, then you can configure MathJax to allow two different delimiters for AsciiMath, one for in-line and one for display mode. I provided this anwser to a similar question in the MathJax User's Forum some years ago:

<!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="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=AM_HTMLorMML"></script>
</head>
<body>

<p>Inline AsciiMath: `sum_{n=1}^10 n^2 = 55`</p>

<p>Display AsciiMath: ``sum_{n=1}^10 n^2 = 55``</p>

</body> 
</html>

The result is:

am-delimiters