ymittal / asciimath Goto Github PK
View Code? Open in Web Editor NEWAsciiMath to LaTeX converter
AsciiMath to LaTeX converter
numbers are restricted to integers, add support for decimals :)
Running this command from README results in weird output.
$ python replace.py --xml samples/asciimath.xml
For example, <m>`sqrt(2) + root 3 2</m>
changes to <m>\sqrt{2} \sqrt[3]{2}</m>
instead of the expected <m>\sqrt{2} + \sqrt[3]{2}</m>
. I see the expected output when I run src/replace.py
standalone.
Inner products are usually written with angle brackets. It looks sort of like this:
<u,v>
except that the delimiters are not angled as sharply. In TeX it is written
\langle u,v\rangle
You might think that AsciiMath would just use the less-than and greater-than
signs, but they can't because of their parsing rules. They offer two options:
shown here:
<<u,v>>
or (:u,v:)
I don't like either of those.
If we insist that the less-than sign, when used as a relation,
have spaces around it, then we are free to let people use a more natural
input for inner product.
There are various other special uses of < and > that need to be taken
into account:
<=, >=, =>, <=>, ->, more
Does this seem workable?
The expression
5 < 6
is valid LaTeX, but including that in a PreTeXt document gives an error
because the less-than character is special in XML.
So unlike standard AsciiMath, in PXT the conversion needs to
write it as
5 \lt 6
Asciimth displays it correctly, LaTeX does not. Our existing implementation should display it as e^{sin(x^2)}
.
An expression like cos(3 x) has two pieces, and we will need a
way to recognize it as one object with two pieces:
the function cosine and its argument.
int 3 x dx has 3 pieces:
(the integral) (of 3 x) (dx)
[do I mean "the antiderivative"?]
log_10(300) has three pieces:
(the log) (base 10) (of 300)
sum_(n=1)^55 3 n has 4 pieces:
(the sum) (from n=1) (to 55) (of 3n)
int_0^1 3 x dx has 5 pieces:
(the integral) (from 0) (to 1) (of 3 x) (dx)
I'd like to discuss what input we need in order to parse these
properly.
In each case, once you identify the base object,
only a few things can happen, and you have to look past a
predetermined number of other objects to determine what
is going on. Once you have the pieces, you understand the
complete object. Then you are ready to do something with it,
such as output to semantic LaTeX.
Some functions are commonly written without parentheses around their
arguments in certain cases, such as
cos 2pi = 1
A convention which seems workable is to consider the argument to continue
until white space or the end of the expression.
The some convention would interpret
e^2x as exp(2x)
Another situation where a similar convention might be workable is in limits
of integrals as in
int_0^2pi cos x dx = 0 .
Except that it would be weird to allow that in the lower limit but not the upper
limit:
int_18pi^26pi sin x = 0
There it is the ^
and not a space that signals the end of the lower limit.
But if that works, then why not
sum_n=1^infty n^-2 = pi/6 ?
I am not advocating either way. I find
sum_n=1^infty harder to read than sum_(n=1)^infty
so maybe there is nothing to be gained by allowing that flexibility everywhere.
It would be nice to have a sharp line delimiting when such grouping has
parentheses optional. Maybe this will become clearer as we test more examples.
Standard AM recognizes d/dx and dy/dx as the fractions \frac{d}{dx} and \frac{dy}{dx} .
I think that behavior should be replicated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.