GithubHelp home page GithubHelp logo

Handling whitespaces about asciimathml HOT 9 OPEN

asciimath avatar asciimath commented on May 3, 2024
Handling whitespaces

from asciimathml.

Comments (9)

Phyks avatar Phyks commented on May 3, 2024 2

Yes. Sorry for the lengthy discussion to narrow it down to this =(

from asciimathml.

Phyks avatar Phyks commented on May 3, 2024

Plus it leads to unwanted issues such as #50.

from asciimathml.

drlippman avatar drlippman commented on May 3, 2024

What should coscos be treated as?
I can't say with certainty, but I believe Peter's philosophy in creating the grammar was to look for known symbols. There's certainly nothing disallowed about using whitespace, and I usually use it for clarity. Whitespace can be used to break a symbol match, so cos h wouldn't match the cosh symbol, but otherwise whitespace isn't relevant.
Whether or not this was a good design choice is debatable, but since ASCIImath is a pretty established language at this point, I don't think we can go changing the underlying grammar at this point without risking breaking a ton of existing places that use it.

On Mar 31, 2016 2:40 AM, Lucas Verney [email protected] wrote:Hi,

Is there any specific reasons to handle coscos as cos cos?

This is not of very great importance, but writing without whitespaces is a pain for readability and introduces a difference between things like cosx (the cosine of x variable) and cosh (the hyperbolic cosine function).

—You are receiving this because you are subscribed to this thread.Reply to this email directly or view it on GitHub

from asciimathml.

Phyks avatar Phyks commented on May 3, 2024

Sure about the well established point. Still, I do not see any way to represent "coprod" in ASCIIMath, without having to write it in a pretty unconventional way ("cop rod" for instance).

cc @Kerl13 who came across this issue as well and might be interested in it.

from asciimathml.

dpvc avatar dpvc commented on May 3, 2024

If you add a symbol for "coprod", then coprod will be properly interpreted as your new symbol. For example, if you are using MathJax, then you can add

MathJax.Hub.Register.StartupHook("AsciiMath Jax Config",function () {
  var AM = MathJax.InputJax.AsciiMath.AM;
  AM.symbols.push(
    {input:"coprod", tag:"mo", output:"\u2210", tex:null, ttype:AM.TOKEN.UNDEROVER}
  );
});
</script>

before the script that loads MathJax.js itself, and you will be able to use things like

`coprod x`

to get "∐x" in the output.

If you are using AsciiMath directly, then there is a command for adding symbols that you can use.

from asciimathml.

Phyks avatar Phyks commented on May 3, 2024

@dpvc Not sure we are talking about the same thing, I should have explained better. Actually, yes, it works if you define a symbol yourself.

Now, imagine I have a variable which is called coprod. I want it to be rendered as it would be with $coprod$ in standard LaTeX. This does not seem to be easily doable in ASCIIMath.

from asciimathml.

dpvc avatar dpvc commented on May 3, 2024

Sorry, I did misunderstand your issue.

If you mean for coprod to be a variable name, then I would recommend following the convention that multi-letter variables are typeset in upright (roman) lettering, not italics. In AsciiMath, you could use text{coprod} or "coprod" for example.

If you want the variable name in italics, then even in LaTeX, $coprod$ is the wrong way to typeset it, since the spacing will not be correct (though for this particular word the difference is quite minor, but for something like office you will see a bigger difference). The recommended way in LaTeX would be to use $\mathit{coprod}$. In addition, using $coprod$ gives the semantics of "c times o times p times r times o times d", not a single variable name. Such distinctions make a difference in situations were users may need assistive technology (like screen readers, or brail output), where the two inputs can give very different spoken output.

Unfortunately, AsciiMath doesn't have a built-in means of specifying italics (it has ones for script, calligraphic, Fraktur, and so on, but not italic). You can add one in a similar fashion to my previous example.

<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("AsciiMath Jax Config",function () {
  var AM = MathJax.InputJax.AsciiMath.AM;
  AM.symbols.push(
    {input:"mit", tag:"mstyle", atname:"mathvariant", atval:"-tex-mathit",
     output:"mathit", tex:null, ttype:AM.TOKEN.UNARY}
  );
});
</script>

Then you can use mit"coprod" or mit{"coprod"} to get "coprod" in italics with proper spacing for a multi-letter variable name.

from asciimathml.

Phyks avatar Phyks commented on May 3, 2024

Sorry, I missed your reply :/

The convention you recommend is then:

  • a (ASCIIMath) or $a$ (LaTeX) for single-letter variables, which are then rendered as italics.
  • "foobar" (or text{foobar}, in ASCIIMath) or $\mathrm{foobar}$ for multiple-letter variables, which are then rendered in roman font.

Is it some widely used convention? I have never seen it (but http://www.shearsoneditorial.com/2012/07/typographical-conventions-for-mathematics/ confirms it). In any case, I think this may be worth a comment in the ASCIIMath doc :)

My issue is about the grammar of ASCIIMath itself, rather than the JS implementation of it. I was discussing the possibility to change it so that variables are parsed as words (thus enforcing the use of whitespaces to separate characters), and render them correctly, a bit as discussed here for LaTeX.

But this is quite a major change (and breaking one) in the grammar, so I am not sure it is something easy to do. Still (if it could not be included in ASCIIMath), do you see any reasons not to do it in another implementation of ASCIIMath?

from asciimathml.

drlippman avatar drlippman commented on May 3, 2024

So the real grammar change you're talking about is introducing some concept of multi-character variables?

from asciimathml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.