Skip to content

Commit

Permalink
Replace ParseNode<*> with a more accurate AnyParseNode and fix flow e…
Browse files Browse the repository at this point in the history
…rrors. (KaTeX#1387)

* Replace ParseNode<*> with a more accurate AnyParseNode and fix flow errors.

* Allow "array" environment type spec to use any all symbol type.

Before this commit, it was constrained to use "mathord" and "textord", but a
recent change in HEAD resulted in a "rel" node being used in the spec for, e.g.
\begin{array}{|l||c:r::}\end{array}

* Address reviewer comments: rename `lastRow` to `row` in array.js.
  • Loading branch information
marcianx authored and kevinbarabash committed Jun 4, 2018
1 parent 4492eed commit 19d2aa6
Show file tree
Hide file tree
Showing 20 changed files with 284 additions and 171 deletions.
4 changes: 2 additions & 2 deletions katex.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,7 @@ import domTree from "./src/domTree";
import utils from "./src/utils";

import type {SettingsOptions} from "./src/Settings";
import type ParseNode from "./src/ParseNode";
import type {AnyParseNode} from "./src/ParseNode";

import {defineSymbol} from './src/symbols';
import {defineMacro} from './src/macros';
Expand Down Expand Up @@ -70,7 70,7 @@ const renderToString = function(
const generateParseTree = function(
expression: string,
options: SettingsOptions,
): ParseNode<*>[] {
): AnyParseNode[] {
const settings = new Settings(options);
return parseTree(expression, settings);
};
Expand Down
7 changes: 4 additions & 3 deletions src/ParseError.js
Original file line number Diff line number Diff line change
@@ -1,7 1,8 @@
// @flow
import ParseNode from "./ParseNode";
import {Token} from "./Token";

import type {AnyParseNode} from "./ParseNode";

/**
* This is the ParseError class, which is the main error thrown by KaTeX
* functions when something has gone wrong. This is used to distinguish internal
Expand All @@ -15,8 16,8 @@ class ParseError {
// Error position based on passed-in Token or ParseNode.

constructor(
message: string, // The error message
token?: Token | ParseNode<*>, // An object providing position information
message: string, // The error message
token?: ?Token | AnyParseNode, // An object providing position information
) {
let error = "KaTeX parse error: " message;
let start;
Expand Down
Loading

0 comments on commit 19d2aa6

Please sign in to comment.