Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WAnt to use math-latex-parser in my project #2

Open
mairakhalil opened this issue Oct 11, 2022 · 0 comments
Open

WAnt to use math-latex-parser in my project #2

mairakhalil opened this issue Oct 11, 2022 · 0 comments

Comments

@mairakhalil
Copy link

I am using mathquill in a project for which I have used tex math parser to parse latex and math.js to evaluate . It is working fine for me but when I am trying to solve hyperbolic functions it throws error undefine I know this is because we dont have hyperbolic functions in tex math parser..So I want to use math-latex-parser because it has build in functions for hyperbolic functions as well What should I do to use it in my below function? I have already tried using mathLatexParser.parse but it throws error at complie

Here is my mathquill function
import { parseTex} from 'tex-math-parser'
export var MQ = MathQuill.getInterface(2);

export var answerSpan = document.getElementById('answer');
export var workingSpan = document.getElementById('working');
export var mathSpan = document.getElementById('math');

export var answerMathField = MQ.MathField(answerSpan, {
handlers: {
edit: function () {
var enteredMath = answerMathField.latex(); // Get entered math in LaTeX format
workingSpan.innerHTML = enteredMath;

    const escapedTex = String.raw `${enteredMath}`; // ES6 raw template string
    let mathJSTree;
 
    try{
         mathJSTree=parseTex(escapedTex);

        
    }catch(err){
        mathSpan.innerHTML="err";
        workingSpan.innerHTML = err;
    }
    try{
        var code = mathJSTree.compile() ;
    }catch(err){
        workingSpan.innerHTML = err;
    }
    try{
        var answer = code.evaluate();
        mathSpan.innerHTML=answer;
    }catch(err){
        workingSpan.innerHTML = err;
   }

}

}
}).focus();
console.log('hello there')

here is my click event on btns
document.getElementById("sinh").onclick = function (){
answerMathField.cmd('\sinh').typedText('(').focus();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant