Add support for \left and \right

Summary:
Added stacked delimiter support for more delimiters. Split out delimiter
functions into its own file, and split out some tree building functions into a
common file. Supports the empty `.` delimiter with \left and \right, and doesn't
try to produce huge /, \backslash, <, or > delimiters. Depends on D7844

Test input:

\left( \left) \left[ \left\lbrack \left] \left\rbrack \left\{ \left\lbrace
\left\} \left\rbrace \left\lfloor \left\rfloor \left\lceil \left\rceil
\left\langle \left\rangle \left/ \left\backslash \left| \left\vert \left\|
\left\Vert \left\uparrow \left\Uparrow \left\downarrow \left\Downarrow
\left\updownarrow \left\Updownarrow {x^{x^{x^{x^{x^{x^{x^{x^{x^{x^x}}}}}}}}}}
\right.\right.\right.\right.\right.\right.\right.\right.\right.\right.
\right.\right.\right.\right.\right.\right.\right.\right.\right.\right.
\right.\right.\right.\right.\right.\right.\right.\right.

Test Plan:
 - Run the test input, see that it works
 - Run the tests, see that they work
 - Look at huxley screenshots (not here yet :( ) and make sure they look good

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D11602
This commit is contained in:
Emily Eisenberg
2014-09-04 21:58:43 -07:00
parent 513ae30fe1
commit c3f758c319
22 changed files with 837 additions and 317 deletions

View File

@@ -8,7 +8,9 @@
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<input type="text" value="\blue\dfrac{\frac{\phi^2}{3}-G_a^{x^3}}{2\times3+4}+\orange\dfrac{(x^2+y^2)^\frac{1}{2}}{\tan\psi^\tau+2/3}" id="input" />
<input type="text"
value="(\left( x \right) \left( x^2 \right) \left( \frac{a}{b} \right) \left( \frac{a^2}{b} \right) \left( \dfrac{a}{b} \right) \left( \dfrac{a^2}{b} \right)"
id="input" />
<div id="math"></div>
<input id="permalink" type="button" value="permalink">
<script src="main.js" type="text/javascript"></script>

View File

@@ -39,6 +39,11 @@ big parens
table-layout: fixed;
}
// This value is also used in fontMetrics.js, if you change it make sure the
// values match.
@ptperem: 10.0;
@nulldelimiterspace: 1.2em / @ptperem;
@thinspace: 0.16667em;
@mediumspace: 0.22222em;
@thickspace: 0.27778em;
@@ -162,6 +167,10 @@ big parens
.reset-scriptscriptstyle.scriptstyle { font-size: 1.4em; }
.reset-scriptscriptstyle.scriptscriptstyle { font-size: 1em; }
.style-wrap {
position: relative;
}
.baseline-align-hack-outer() {
display: inline-block;
}
@@ -392,12 +401,18 @@ big parens
.baseline-align-hack-middle;
position: relative;
&.size1 {
> span {
font-family: KaTeX_Size1;
}
&.size1 > span {
font-family: Katex_Size1;
}
&.size4 > span {
font-family: Katex_Size4;
}
}
}
}
.nulldelimiter {
display: inline-block;
width: @nulldelimiterspace;
}
}