Commit Graph

16 Commits

Author SHA1 Message Date
Kevin Barabash
151376e8aa Port katex-a11y.js to KaTeX (#2062)
* copy katex-a11y.js from webapp to contrib/to-a11y-string.js

* first pass of updating to-a11y-string to use flow

* Set up test harness and write some tests
- add flow types for jest
- create wallaby config file
- add prettier as a dep and set up .prettierrc so that we use .toMatchInlineSnapshot() and have jest insert the snapshot for us
- add lots of TODOs (I'll create tickets for these later)

* Add some  to get the tests passing for now

* remove commented out parts of wallaby.js config file

* remove some stale strings, fix flow issue, add more coverage

* add , add few more tests, handle middle

* fix minor nits in tests

* rename to-a11y-string to render-a11y-string, updatte webpack config to build extension

* add test for \boxed

* remove commented out code
2019-08-02 11:24:51 -04:00
Ron Kok
2b83935064 Improve MathML for classes (#1929)
* Improve MathML for classes

* Fix lint errors

* Fix another lint error

* Simplify MathML resulting from single character box

* Fix lint errors

* make some of the arrays in our html/mathml helper functions readonly
2019-07-05 01:14:05 -04:00
Ron Kok
f8f4809886 Fix ApplyFunction character (#1890) 2019-03-23 10:30:33 +09:00
Ashish Myles
e7a45221c4 Rename .body/.value to .name/.body in "op" ParseNode. (#1612)
* Rename .body to .name in "op" ParseNode.

* Rename .value to .body in "op" ParseNode.
2018-08-14 13:02:24 +09:00
Ashish Myles
fcc5c4420a Rename .value to .body in "ordgroup". (#1609) 2018-08-13 23:17:23 +09:00
Ashish Myles
1506dc1d88 Flatten a bunch of non-pervasive ParseNode types (part 1) (#1551)
* Flatten "url" ParseNode.

* Flatten "href" ParseNode.

* Flatten "verb" ParseNode.

* Flatten "tag" ParseNode.

* Flatten "cr" ParseNode.

* Flatten "delimsizing" ParseNode.

* Flatten "middle" ParseNode.

* Flatten "leftright" ParseNode.

* Flatten "leftright-right" ParseNode.

* Flatten "mathchoice" ParseNode.

* Remove unused ParseNode type "mod".

* Flatten "mclass" ParseNode.

* Flatten "font" ParseNode.

* Flatten "phantom" ParseNode.

* Flatten "hphantom" ParseNode.

* Flatten "vphantom" ParseNode.
2018-08-06 11:49:43 +09:00
Ashish Myles
fd6690b988 Flatten ParseNodes: "supsub" and related ("accent", "accentUnder", "horizBrace", "xarrow", "op"). (#1542) 2018-08-03 14:06:02 +09:00
Ashish Myles
7e97a382ec Introduce "atom" parse node to coalesce various symbol nodes. (#1541) 2018-08-02 20:46:40 +09:00
Ashish Myles
0ac4b6e89d Convert ParseNode to struct (#1534)
* Define the nested version of ParseNodes structs explicitly.

Passes test:jest, but fails test:flow.

* Fix additional type errors reported by flow.

* Migrate rebased code from master.

* Rename ParseNode.js to parseNode.js.

* Update defineEnvironment output type to fix the flow errors in environment/array.js.
2018-08-01 15:41:27 +09:00
Erik Demaine
578877764d \@binrel command and refactor (#1487)
* \@binrel command and refactor

New `\@binrel{x}{y}` command renders `y` as if it's a bin/rel/ord like `x`.
This is equivalent to AMSTeX's `\binrel@{x}\binrel@@{y}`.
It will hopefully be useful for macros, such as `\pmb` (#1418).

Also refactor the (already duplicated) code for implementing this
functionality into buildCommon.binrelClass.

* Add tests; fix flow error

* Another test

* Move binrelClass to functions/mclass.js

* Remove expensive array destructuring polyfill
2018-07-17 19:49:50 -07:00
Ashish Myles
f0976ade26 Refactor documentFragment and implement both HtmlDomNode and MathDomNode interfaces (stepping stone to port buildMathML to flow) (#1478)
* Make MathNodeClass include documentFragment for ergonomics.

* Separate out the HTML and MathML documentFragments.

These two documentFragments have different additional properties/methodsi
and limitations. This separation is needed for porting buildMathML to
flow.

* Coalesce the documentFragment subclasses to avoid subclassing polyfill.

* Make DomSpan and SvgSpan type aliases again instead of subclasses.

* Remove type MathNodeClass in favor of MathDomNode.

* Resolve $FlowFixMes by reordering variants of a union type.
2018-07-16 15:41:27 +09:00
Erik Demaine
b7277049a4 \char character escaping and nicer MathML via \html@mathml (#1454)
* \html@mathml

Fix #1452

* Add missing file

* Implement \char (via internal \@char)

* Remove excess <mstyle> wrapper on \mathbin etc.

* Fix tests

* Add Unicode support for \copyright and \textregistered

Testing that this doesn't lead to an infinite loop thanks to \char` escaping.

* Add tests

* Use assertNodeType

* Switch from regex to lookup table, and no parseInt
2018-07-14 08:36:23 -04:00
Erik Demaine
4a2903148e Automatic mrel/mbin spacing for \boldsymbol (#1388)
* Automatic mrel/mbin spacing for \boldsymbol

Fix #1154

* Add test

* Add missing mode

* Separate out \boldsymbol support to correct flow types

* Fix ternaries thanks to @ronkok's comment

* Revert package-lock.json

* Add screenshot test
2018-06-11 08:19:50 -04:00
Kevin Barabash
9d2722f879 update function handlers to return a ParseNode (#1393)
* update function handlers to return a ParseNode

* remove FlowFixMes
2018-06-02 13:05:15 -04:00
Kevin Barabash
3ec752f5f1 Make ParseNodeTypes more regular (#1373)
Make ParseNodeTypes more regular: make 'size' and 'url' node values be objects.
2018-05-28 12:55:59 -04:00
Ashish Myles
f49a524da7 Move "mclass" node logic to functions/mclass. (#1325)
* Move "mclass" node logic to functions/mclass.
2018-05-18 12:44:28 -04:00