GithubHelp home page GithubHelp logo

asciimath2tex's People

Contributors

christianp avatar dependabot[bot] avatar stefaans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

asciimath2tex's Issues

Issue involving parentheses

I have the following AsciiMath expression:

P(B|A) = (P(A|B) * P(B))/(P(A))

Which this library converts to:

P \left( B \left \lvert A \right ) = \left( P \frac{A \left \lvert B \right ) \cdot P \left( B \right )}{P \left( A \right )} \right. \right.

Then rendering it via KaTeX I get:

Screen Shot 2019-07-01 at 00 25 35

While instead I should get:

image

I'm no TeX expert, I guess the generated TeX isn't quite right? ๐Ÿค”

Parsing not correctly

When I'm trying to parse this string:
{\displaystyle \frac{{m}}{{n}},\quad\text{gdzie}\quad{m},{\;n}\in{{{\mathbb{Z}}}}\quad\text{oraz}\quad{n}\ne{0}}

the output is:
\left\lbrace d i s p l a y s t y \le \frac{\left\lbrace m \right \rbrace}{\left\lbrace n \right \rbrace} , \quad \text{gdzie} \quad \left\lbrace m \right \rbrace , \left\lbrace ; n \right \rbrace \in \left\lbrace \left\lbrace \left\lbrace \mathbb{Z} \right \rbrace \right \rbrace \right \rbrace \quad \text{oraz} \quad \left\lbrace n \right \rbrace \ne \left\lbrace 0 \right \rbrace \right \rbrace

Am I doing something wrong, or the string is wrong?

Please add type declarations to npm package

To use asciimath2tex in a TypeScript project, we need type definitions. The following works for me and may be a solution for you too:

In packages.json, specify the type definitions file:

"typings": "type.d.ts",

Add file type.d.ts:

export as namespace asciimath2tex;

class AsciiMathParser {
  constructor();
  parse(str): string;
}

export default AsciiMathParser;

With the type definitions in place, I can do:

import AsciiMathParser from 'asciimath2tex';
...
...
const parser = new AsciiMathParser();
const tex = parser.parse("int_(i=1)^10 x^2/2 dx");

Unable to parse an expression containing 2 commas one by one or an empty string with a comma when using ECMAScript module

Hello!
I use your parser as an ECMAScript module and I see that I cannot pass an expression that contains ',,' (or simply ',' as the whole expression). The exception occurs:

asciimath2tex.js:455 Uncaught Error: Didn't EOF: 
    at AsciiMathParser.consume (asciimath2tex.js:455)
    at AsciiMathParser.parse (asciimath2tex.js:420)
else if(!this.eof(pos)) {
	throw(new Error("Didn't EOF: ",this.source(pos)));
}

However, if I include the parser as a CommonJS module taking the source code directly from the repository, the expressions are parsed fine, as in asciimath2tex.js the exception is not thrown for the same case. Instead, there are:

else if (!this.eof(t)) {
	var h = this.source(t, t + 1);
	a.push({tex: h, pos: t, ttype: "character"}), (e += h), (t += 1);
}

Could you explain, please, why there is a difference between the scripts and what behavior of the parser is correct?

"not subset" and "not exists" commands

!in renders as \not\in. There should be similar commands for \not\exists and \not\subset.

In fact, maybe ! before any relation should render as \not. Ideally, this should go in the official AsciiMath too.

Publish to NPM

Hey I'd like to give this a try, could you publish it to NPM and add a proper license (MIT perhaps)?

Sequence "\ " ignored

I suspect that in the method strip_space the regex should be corrected in /^(\s|\\(?!\\\s))*/. As it is now, the sequence \ is simply stripped, instead of being translated in \, (that is the thin space). The rendering in MathML seem to confirm that this is what should happen, and also MathJax does so. The examples in the tests where \ is used seem on the contrary not correct. Am I right?

Edit Readme

It has new Parser(); instead of new AsciiMathParser();

Please bump npm version

Christian, could you please bump the version number of the npm package? That way the recent packages.json with typing definitions will be installed and the build performed with the types definition file. Working on the npm package is above my pay grade :)

CommonJS export

It would be useful to have a CommonJS export, so that this library can be easily imported in CommonJS environments (like Node.js).

\twoheadrightarrowtail support

Hi all. I'm working on implement LaTeX output support support for asciidoctor/asciimath, which is quite similar to what you guys are doing in here.

As stated in here, KaTeX does not support the \twoheadrightarrowtail macro (neither do vanilla LaTeX, amsmath or amssymb). In fact, I was surprised that I couldn't find a TeX package that supports this specific symbol.

Did you guys have any luck with this? I believe we should exchange information about this issue.

Matrices in parentheses not rendering correctly

I'm using [email protected]. There seems to be something funky going on if I wrap a matrix in parentheses. I noticed this when trying to mark up a matrix determinant with the following input:

parser.parse('det([[a,b],[c,d]])');

Expected output:

'\det{\left ( \left [ \begin{matrix} a & b \\ c & d \end{matrix} \right ] \right )}'

Actual output:

'\det{\left ( \begin{matrix} \left [ a , b \right ] & \left [ c , d \right ] \end{matrix} \right )}'

It seems that the minimal test case that fails is

parser.parse('([[a],[b]])');

Expected output:

'\left ( \left [ \begin{matrix} a \\ b \end{matrix} \right ] \right )'

Actual output:

'\left ( \begin{matrix} \left [ a \right ] & \left [ b \right ] \end{matrix} \right )'

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.