mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-22 10:58:40 +00:00
[breaking] trust setting to indicate whether input text is trusted (#1794)
* trust option to indicate whether input text is trusted * Revamp into trust contexts beyond just command * Document new trust function style * Fix screenshot testing * Use trust setting in \url and \href * Check `isTrusted` in `\url` and `\href` (so now disabled by default) * Automatically compute `protocol` from `url` in `isTrusted`, so it doesn't need to be passed into every context. * Document untrusted features in support list/table * Existing tests trust by default * remove allowedProtocols and fix flow errors * remove 'allowedProtocols' from documentation * add a comment about a flow error, rename urlToProtocol to protocolFromUrl * add tests test that use function version of trust option * default trust to false in MathML tests * fix test title, remove 'trust: false' from test settings since it's the default
This commit is contained in:
committed by
Kevin Barabash
parent
fc79f79c78
commit
3800dc49c1
@@ -2,7 +2,8 @@
|
||||
import {checkNodeType} from "./parseNode";
|
||||
|
||||
import type Parser from "./Parser";
|
||||
import type {ParseNode, AnyParseNode, NodeType} from "./parseNode";
|
||||
import type {ParseNode, AnyParseNode, NodeType, UnsupportedCmdParseNode}
|
||||
from "./parseNode";
|
||||
import type Options from "./Options";
|
||||
import type {ArgType, BreakToken, Mode} from "./types";
|
||||
import type {HtmlDomNode} from "./domTree";
|
||||
@@ -21,7 +22,9 @@ export type FunctionHandler<NODETYPE: NodeType> = (
|
||||
context: FunctionContext,
|
||||
args: AnyParseNode[],
|
||||
optArgs: (?AnyParseNode)[],
|
||||
) => ParseNode<NODETYPE>;
|
||||
) => UnsupportedCmdParseNode | ParseNode<NODETYPE>;
|
||||
// Note: reverse the order of the return type union will cause a flow error.
|
||||
// See https://github.com/facebook/flow/issues/3663.
|
||||
|
||||
export type HtmlBuilder<NODETYPE> = (ParseNode<NODETYPE>, Options) => HtmlDomNode;
|
||||
export type MathMLBuilder<NODETYPE> = (
|
||||
@@ -199,10 +202,6 @@ export default function defineFunction<NODETYPE: NodeType>({
|
||||
handler: handler,
|
||||
};
|
||||
for (let i = 0; i < names.length; ++i) {
|
||||
// TODO: The value type of _functions should be a type union of all
|
||||
// possible `FunctionSpec<>` possibilities instead of `FunctionSpec<*>`,
|
||||
// which is an existential type.
|
||||
// $FlowFixMe
|
||||
_functions[names[i]] = data;
|
||||
}
|
||||
if (type) {
|
||||
|
Reference in New Issue
Block a user