Commit Graph

390 Commits

Author SHA1 Message Date
newman101
bc4693a71b Resolved Issue #370 2015-10-19 16:57:04 +01:00
Kevin Barabash
d87ee4f78f Merge pull request #366 from Khan/add_width_to_font_metrics
Add a build step to generate extended metrics that additionally contain glyph widths
2015-10-16 14:41:31 -07:00
Kevin Barabash
1573e1eed6 Add a build step to generate extended metrics that additionally contain glyph widths
Summary:
The ability to use pre-determined character widths will benefit alternative
layout engines such as gagern's canvas layout engine.  I would also like to
experiment would using CSS transforms to absolutely position each glyph.  This
diff adds a new make rule, make extended_metrics, which generates metrics that
also containing glyph widths.

Test Plan:
- run `make extended_metrics`
- verify that fontMetricsData.js contains entries with 5 numbers instead of 4

Reviewers: emily alpert
2015-10-16 14:31:08 -07:00
Kevin Barabash
ee88cc3c11 Merge pull request #363 from gagern/modeStateful
Make mode part of the internal state of the parser
2015-10-05 16:36:05 +00:00
Kevin Barabash
9aab9c1efe Merge pull request #361 from crepererum/feature/gt_lt
Add \gt and \lt
2015-10-05 16:32:49 +00:00
Marco Neumann
95e568ed6b Add \gt and \lt 2015-10-05 08:34:03 +02:00
Martin von Gagern
cabc08598b Make mode part of the internal state of the parser
This is the first step towards #266.
2015-10-04 20:35:43 +02:00
Kevin Barabash
e9f4b07611 Merge pull request #364 from gagern/lexerRewrite
Refactor lexer, avoiding some mode-specific distinctions
2015-10-03 13:31:51 -07:00
Martin von Gagern
d423bec089 Rewrote lexer, avoiding some mode-specific distinctions
There are two main motivations for this commit.  One is unicode input, which
requires unicode characters to get past the lexer.  See discussion in #261.
The second is in preparation for #266, where we'd deal with one token of
look-ahead but might be lexing that token in an unknown mode in some cases.
The unit test shipped with this commit addresses the latter concern, since
it checks that a math-mode-only token may immediately follow some text mode
content group.

In this new implementation, all the various things that could get matched
have been collected into a single regular expression.  The hope is that
this will be beneficial for performance and keep the code simpler.
The code was written with Unicode input in mind, including non-BMP codepoints.

The role of the lexer as a gate keeper, keeping out invalid TeX syntax, has
been abandoned.  That role is still fulfilled by the symbols and functions
tables, though, since any input which is neither a symbol nor a command is
still considered invalid input, even though it lexes successfully.
2015-10-02 20:06:03 +02:00
Kevin Barabash
95e2f1c8d7 Merge pull request #356 from gagern/callingConvention
New calling convention for functions and environments
2015-10-01 08:42:52 -07:00
Martin von Gagern
30f7a1c5bf New calling convention for functions and environments
Fixes issue #255.

Mixing the variable number of arguments a function receives from TeX code
with the fixed arguments which the parser provides can cause some confusion.
After this change, a handler will receive exactly two arguments: one is a
context object from which things provided by the parser can be accessed by
name, which allows for simple extensions in the future.  The other is the
list of TeX arguments, passed as an array.

If we ever switch to EcmaScript 2015, we might want to use its destructuring
features to name the elements of the args array in the function head.  Until
then, destructuring that array manually immediately at the beginning of the
function seems like a useful convention to easily find the meaning of these
arguments.
2015-10-01 13:15:44 +02:00
Kevin Barabash
a81c4fe78d Merge pull request #362 from Khan/array_font_metrics
Use an array of values instead of object literals to save space in fontMetricsData.js
2015-09-30 10:00:23 -07:00
Kevin Barabash
6a10237017 Use an array of values instead of object literals to save space in fontMetricsData.js
Test Plan: make test

Reviewers: emily
2015-09-29 22:16:03 -07:00
Kevin Barabash
fdbdb28617 Merge pull request #346 from gagern/splitSymbols
Reformat symbol table
2015-09-25 14:56:18 -07:00
Kevin Barabash
f25829df58 Redirect people to gitter instead of freenode 2015-09-25 14:35:23 -07:00
Kevin Barabash
8e54d6e365 Merge pull request #360 from gitter-badger/gitter-badge-1
Add a Gitter chat badge to README.md
2015-09-25 14:32:23 -07:00
The Gitter Badger
b9b8396b6f Add Gitter badge 2015-09-25 21:28:31 +00:00
Kevin Barabash
3203959b96 Merge pull request #352 from Khan/fix_font_greediness
Set the greedines of font functions to 2 so that e^\mathbf{x} will parse
2015-09-25 14:20:23 -07:00
Kevin Barabash
b98670b8ed Set the greedines of font functions to 2 so that e^\mathbf{x} will parse
Test Plan: make test

Reviewers: emily
2015-09-25 14:17:23 -07:00
Emily Eisenberg
961e1caba9 Merge pull request #359 from xymostech/fix-zero-rule-padding
Remove 3px border around rules.
2015-09-22 13:16:18 -07:00
Emily Eisenberg
252f6320ef Remove 3px border around rules.
Summary: For some reason, adding `border-style: solid` also adds a 3px
border around elements, which means that all of the rules that we
created are 3px too large. This sets the default size to 0 for all the
edges, which makes them correct.

Test plan:
 - See that `a\rule{0em}{0em}b` produces no visible rule.
 - See the new screenshots look reasonable.
2015-09-22 10:21:33 -07:00
Kevin Barabash
d7d1367558 Merge pull request #347 from gagern/splitEnvironments
Split up environments list into calls to defineEnvironment
2015-09-14 22:51:04 -06:00
Kevin Barabash
0fc77e2f40 Merge pull request #345 from gagern/splitFunctions
Split up functions list into calls to defineFunction
2015-09-14 22:44:21 -06:00
Kevin Barabash
112e6783b3 Merge pull request #349 from gagern/texcmpLogo
Make texcmp work again, including KaTeX logo
2015-09-11 11:43:28 -07:00
Martin von Gagern
2e0f11bdfa Reindent some comment code as well 2015-09-11 09:27:47 +02:00
Kevin Barabash
89e0d7950c Merge pull request #348 from gagern/splitBuildHandlers
Split groupType literals in buildHTML and buildMathML
2015-09-10 22:36:13 -07:00
Martin von Gagern
71881e3d36 Make texcmp work again, including KaTeX logo
Since all the math font test cases use the KaTeX logo, we need that.
I started with the definition of the logo from katex.less, but tweaked that
until it gave a good visual match, in particular a very similar logo width,
no matter the actual numbers.

With that logo, most tests can be compiled again, with the exception of the
one containing illegal functions to test visual error reporting.
That one needs to be explicitely disabled.
2015-09-10 16:05:23 +02:00
Martin von Gagern
d809f9c362 Reindent groupType definitions in buildHTML and buildMathML
Since the previous commit deliberately avoided reindenting, this one here
does just that: reindenting the existing code.  There are no other changes.
2015-09-10 11:47:47 +02:00
Martin von Gagern
6bc7cd574f Split up groupType map in buildHTML and buildMathML code
Having long object literals containing the code is problematic.
It makes it difficult to add auxiliary functions or data close to the
function inside the map where it is needed.
Building the map in several steps, repeating the map name at each step,
avoids that problem since it makes the definitions independent from one
another, so anything can go between them.

This commit deliberately avoided reindenting existing code to match the new
surroundings.  That way it is easier to see where actual changes happen,
even when not performing a whitespace-ignoring diff.
2015-09-10 11:34:34 +02:00
Martin von Gagern
dae3a14744 Reindent environments
Since the previous commit deliberately avoided reindenting, this one here
does just that: reindenting the existing code.
2015-09-10 11:18:11 +02:00
Martin von Gagern
2a31a719ec Split up environments list into calls to defineEnvironment
Having one long array literal to contain the code of all environment
implementations is problematic.  It makes it difficult to add auxiliary
functions or data close to the function inside the list where it is needed.

Now the functions are no longer defined using such a literal, but instead
using calls to a "defineEnvironment" function which receives all the
relevant data.  Since each function call is independent from the others,
anything can go in between.

This commit deliberately avoided reindenting existing code to match the new
surroundings.  That way it is easier to see where actual changes happen,
even when not performing a whitespace-ignoring diff.
2015-09-10 11:14:00 +02:00
Martin von Gagern
acfdc9f698 Rename declareFunction to defineFunction
https://github.com/Khan/KaTeX/pull/262#issuecomment-113981142 indicated a
preference for define over declare.
2015-09-10 10:23:58 +02:00
Martin von Gagern
414f9dd248 Reformat symbol table
Using function calls instead of one big object literal for the symbols makes
the notation far more concise and readable.  Having the actual symbol name
in the last position helps aligning the preceding columns, making the list
easier to read.

Another benefit is that all symbol definitions now pass through a single
function, where additional processing (e.g. for Unicode input) might take
place in a future commit.
2015-09-10 10:22:42 +02:00
Martin von Gagern
3e055f84e9 Reindent
Since the previous commit deliberately avoided reindenting, this one here
does just that: reindenting the existing code.  There are no other changes.
Notice how the new indentation leaves more room to function handlers.
2015-09-10 09:52:00 +02:00
Martin von Gagern
d553353204 Split up functions list into calls to declareFunction
Having one long array literal to contain the code of all function
implementations is problematic.  It makes it difficult to add auxiliary
functions or data close to the function inside the list where it is needed.

Now the functions are no longer defined using such a literal, but instead
using calls to a "declareFunction" function which receives all the relevant
data.  Since each function call is independent from the others, anything can
go in between.

This commit deliberately avoided reindenting existing code to match the new
surroundings.  That way it is easier to see where actual changes happen,
even when not performing a whitespace-ignoring diff.
2015-09-10 09:45:02 +02:00
Martin von Gagern
5539226f4b Strip one level of indirection from functions module exports 2015-09-10 09:22:24 +02:00
Kevin Barabash
8accf0f18a Merge pull request #342 from xymostech/rename-breakOnUnsupportedCmds
Rename breakOnUnsupportedCmds to throwOnError.
2015-09-01 18:49:33 -06:00
Emily Eisenberg
d6cec8a861 Rename breakOnUnsupportedCmds to throwOnError.
Also, the MathBb-chrome test changed, to what I believe is the correct
result? Not sure why it looked wrong before.

Test plan:
 - `make test`
 - take screenshots, see nothing changed.
2015-09-01 16:51:03 -07:00
Kevin Barabash
c428abca1e Merge pull request #292 from kevinb7/fonts-p3_mathml
Adds MathML support for math font commands.
2015-09-01 09:00:16 -06:00
Kevin Barabash
64e63d7546 Adds MathML support for math font commands.
This is part 3 or 3.  The first two pull requests added font metrics, HTML rendering, and screenshot tests.
2015-08-30 17:24:04 -06:00
Kevin Barabash
07dc11ccb0 Merge pull request #341 from gagern/pngRepack
(Re-)Create some more screenshots in a reproducible way
2015-08-30 16:32:58 -06:00
Martin von Gagern
9c2a391ff6 (Re-)Create some more screenshots in a reproducible way
When rebasing for 2e002ff37a I forgot to
re-create the screenshots based on the new parent.  As a consequence, the
font testing images from fd2d58fd80 were not
updated for Firefox and not even included for Chrome.

We still have the strange issue that Lap can result in one of two possible
screenshots, and while the previous commit recreated one of them, this one
here recreates the other.
2015-08-30 23:09:42 +02:00
Kevin Barabash
f488a7c48d Merge pull request #340 from gagern/pngRepack
Use jspngopt and pako to create reproducible PNG files for Chrome as well
2015-08-29 18:57:40 -06:00
Martin von Gagern
2e002ff37a Use jspngopt and pako to create reproducible PNG files for Chrome as well
The combination of jspngopt and pako should eliminate possible causes for
different PNG encodings, although the core reason for #325 remains unknown.
Pako has poorer compression rates than native libz, but optimization can
counter that effect, and actually reduce the size of the screenshots.

The screenshots for LimitControls and UnsupportedCmds on Firefox used to
exhibit subpixel rendering before, for reasons unknown.  The regenerated
versions don't exhibit this.  See #324 for a discussion.
2015-08-30 02:12:55 +02:00
Kevin Barabash
72027a1a56 Merge pull request #330 from xymostech/add-vert-separator
Add | column separators to arrays.
2015-08-28 10:29:26 -06:00
Emily Eisenberg
3a8adbf595 Add | column separators to arrays.
This adds the ability to add `|` to a column description and have
vertical separators be added. I added types to the column descriptions
and added some logic to handle the separators when building the vertical
lists of the array.

Test plan:
 - See the Arrays screenshot looks good.
 - `make test`
2015-08-28 08:50:42 -07:00
Kevin Barabash
1b5834d894 Merge pull request #334 from Khan/revert-333-gitter-badge
Revert "Add a Gitter chat badge to README.md"
2015-08-21 21:19:25 -06:00
Kevin Barabash
d772aab6d5 Revert "Add a Gitter chat badge to README.md" 2015-08-21 21:14:55 -06:00
Kevin Barabash
bc4c270220 Merge pull request #333 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-08-21 21:06:08 -06:00
The Gitter Badger
2af1ad2ffc Added Gitter badge 2015-08-22 02:55:03 +00:00