ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
638 stars 100 forks source link

Parser for simple arithmetic syntax #42

Open FoggyFinder opened 7 years ago

FoggyFinder commented 7 years ago

Do you have any plans to add possibility of rendering LaTeX formulas from a normal string?

alexreg commented 7 years ago

What do you mean by a "normal string"?

ForNeVeR commented 7 years ago

@FoggyFinder currently the user have the following options:

  1. Render your "string" in a WPF control, like in an example:

    <controls:FormulaControl Formula="\left(x^2 + 2 \cdot x + 2\right) = 0" />

    (that string seems normal enough to me)

  2. Render the formula to WPF DrawingVisual object (for example, if user need to implement his/her own control): FormulaControl.xaml.cs, line 81—88.

  3. Render the formula to SVG or bitmap from Geometry acquired from TexRenderer like in the example.

In all cases the input is the same LaTeX markup string. There aren't any other options for input encoding, but we're considering other possibilities: for example, MathML.

If you want to request some other functionality, then please clarify your question.

gsomix commented 7 years ago

I think "normal string" is something like "1/(1-x)". Just standard mathematical notation from programming languages, that should be parsed as "\frac{1}{1-x}".

ForNeVeR commented 7 years ago

Got it. That makes sense. Although currently I have no plans to implement any alternate markups (such as MathML or this simple arithmetic language) in the nearest future. (But I'm always ready to accept community contributions like this.)

Extendable or replaceable parser will be on the list of possible features, though. @FoggyFinder, thanks for your suggestion.

charlesroddie commented 6 years ago

@foggyfinder Best to parse into an expression, an F# DU ideally, and then convert the expression to a latex string. Math.net symbolics may be able to do that if you don't want to roll your own; if you do want to I can help.

FoggyFinder commented 6 years ago

@charlesroddie Thank you, I know about MathNet.Symbolics but its capabilities are rather limited.

I'm totally agree with you - F# would be good choice to do it.

charlesroddie commented 6 years ago

@FoggyFinder I have a more advanced TeX parser but unfortunately it's a trade secret. Happy to help you with a simple arithmetic one though!

I'm mulling over porting this library to F# to get to know and simplify the code, in preparation for working on TeX editing.

B3zaleel commented 6 years ago

That is the ASCII math notation, they have an asciimathml converter, we could use that to get the mathml format and then translate it to the tex format.