Commit Graph

10 Commits

Author SHA1 Message Date
Martin von Gagern
8c55aed39a Allow macro definitions in settings (#493)
* Introduce MacroExpander

The job of the MacroExpander is turning a stream of possibly expandable
tokens, as obtained from the Lexer, into a stream of non-expandable tokens
(in KaTeX, even though they may well be expandable in TeX) which can be
processed by the Parser.  The challenge here is that we don't have
mode-specific lexer implementations any more, so we need to do everything on
the token level, including reassembly of sizes and colors.

* Make macros available in development server

Now one can specify macro definitions like \foo=bar as part of the query
string and use these macros in the formula being typeset.

* Add tests for macro expansions

* Handle end of input in special groups

This avoids an infinite loop if input ends prematurely.

* Simplify parseSpecialGroup

The parseSpecialGroup methos now returns a single token spanning the whole
special group, and leaves matching that string against a suitable regular
expression to whoever is calling the method.  Suggested by @cbreeden.

* Incorporate review suggestions

Add improvements suggested by Kevin Barabash during review.

* Input range sanity checks

Ensure that both tokens of a token range come from the same lexer,
and that the range has a non-negative length.

* Improved wording of two comments
2016-07-08 12:24:31 -07:00
Ben Alpert
317564a173 Catch exceptions on test page
Summary: This makes typing into the box bearable with break-on-exception enabled.

Test Plan: Typed into box; I didn't blow up.

Reviewers: emily

Reviewed By: emily

Subscribers: jessie

Differential Revision: http://phabricator.khanacademy.org/D13314
2014-09-22 11:46:26 -07:00
Emily Eisenberg
6b674873ea Rename katex.process to katex.render
Test plan:
 - Make sure tests work and huxley tests didn't change

Auditors: alpert
2014-09-14 21:20:27 -07:00
Ben Alpert
5a94faac9e Render nothing for /?text=
Test Plan: Went to /?text=, saw nothing (instead of the default).

Auditors: emily
2014-09-05 23:57:29 -07:00
Emily Eisenberg
fa3df2db6f Make permalink button work in IE8.
IE8 doesn't have addEventListener, so use attachEvent if that doesn't exist.

Auditors: alpert
2014-08-26 14:50:38 -07:00
Ben Alpert
6dd6032ebc Add permalink button to test page
Auditors: emily
2014-07-23 20:24:09 -07:00
Emily Eisenberg
62b4e68a1c Make safari only break on fractions
Summary: Also, make errors on the initial parse not prevent further
parses.

Auditors: alpert
2013-07-25 19:15:16 -07:00
Emily Eisenberg
adb8b5d671 Rename everything to KaTeX
Summary: Rename all instances of mjlite -> katex

Test Plan: Run the local server, make sure things still work.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D2977
2013-07-10 14:08:50 -07:00
Ben Alpert
d5c2a6fb38 Make things sort of work in IE8
Summary:
Uploaded the OTFs from eab3322d to fontsquirrel with the following config:

```
{"mode":"expert","formats":["ttf","woff","eotz"],"tt_instructor":"default","fix_vertical_metrics":"Y","fix_gasp":"xy","add_spaces":"Y","add_hyphens":"Y","fallback":"none","fallback_custom":"100","options_subset":"none","subset_custom":"","subset_custom_range":"","css_stylesheet":"stylesheet.css","filename_suffix":"","emsquare":"2048","spacing_adjustment":"0"}
```

Now we have this beauty in IE8:

{F213}

and it looks similar in Chrome. Now I guess we just need square roots so we can stop disseminating the wrong quadratic formula.

Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D43
2013-07-08 22:48:14 -07:00
Ben Alpert
4bc599966f Create node server to replace 'make watch'
Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D38
2013-07-05 22:55:10 -07:00