New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: copied d.ts types from DefinitelyTyped #3846
Open
kelvinsjk
wants to merge
2
commits into
KaTeX:main
Choose a base branch
from
kelvinsjk:dts-types
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,162 @@ | ||||||
// Type definitions for KaTeX 0.16 | ||||||
// Project: https://katex.org/ | ||||||
// Definitions by: Michael Randolph <https://github.com/mrand01> | ||||||
// Kevin Nguyen <https://github.com/knguyen0125> | ||||||
// bLue <https://github.com/dreamerblue> | ||||||
// Sebastian Weigand <https://github.com/s-weigand> | ||||||
// sapphi-red <https://github.com/sapphi-red> | ||||||
// Stefaans <https://github.com/Stefaans> | ||||||
// Definitions copied from: https://github.com/DefinitelyTyped/DefinitelyTyped | ||||||
// on 2023-08-07 by Kelvin Soh <https://github.com/kelvinsjk> | ||||||
|
||||||
export interface TrustContext { | ||||||
command: string; | ||||||
url: string; | ||||||
protocol: string; | ||||||
} | ||||||
|
||||||
/** Documentation: https://katex.org/docs/options.html */ | ||||||
export interface KatexOptions { | ||||||
/** | ||||||
* If `true`, math will be rendered in display mode | ||||||
* (math in display style and center math on page) | ||||||
* | ||||||
* If `false`, math will be rendered in inline mode | ||||||
* @default false | ||||||
*/ | ||||||
displayMode?: boolean | undefined; | ||||||
/** | ||||||
* Determines the markup language of the output. The valid choices are: | ||||||
* - `html`: Outputs KaTeX in HTML only. | ||||||
* - `mathml`: Outputs KaTeX in MathML only. | ||||||
* - `htmlAndMathml`: Outputs HTML for visual rendering | ||||||
* and includes MathML for accessibility. | ||||||
* | ||||||
* @default 'htmlAndMathml' | ||||||
*/ | ||||||
output?: 'html' | 'mathml' | 'htmlAndMathml' | undefined; | ||||||
/** | ||||||
* If `true`, display math has \tags rendered on the left | ||||||
* instead of the right, like \usepackage[leqno]{amsmath} in LaTeX. | ||||||
* | ||||||
* @default false | ||||||
*/ | ||||||
leqno?: boolean | undefined; | ||||||
/** | ||||||
* If `true`, display math renders flush left with a 2em left margin, | ||||||
* like \documentclass[fleqn] in LaTeX with the amsmath package. | ||||||
* | ||||||
* @default false | ||||||
*/ | ||||||
fleqn?: boolean | undefined; | ||||||
/** | ||||||
* If `true`, KaTeX will throw a `ParseError` when | ||||||
* it encounters an unsupported command or invalid LaTex | ||||||
* | ||||||
* If `false`, KaTeX will render unsupported commands as | ||||||
* text, and render invalid LaTeX as its source code with | ||||||
* hover text giving the error, in color given by errorColor | ||||||
* @default true | ||||||
*/ | ||||||
throwOnError?: boolean | undefined; | ||||||
/** | ||||||
* A Color string given in format `#XXX` or `#XXXXXX` | ||||||
*/ | ||||||
errorColor?: string | undefined; | ||||||
/** | ||||||
* A collection of custom macros. | ||||||
* | ||||||
* See `src/macros.js` for its usage | ||||||
*/ | ||||||
macros?: any; | ||||||
/** | ||||||
* Specifies a minimum thickness, in ems, for fraction lines, | ||||||
* \sqrt top lines, {array} vertical lines, \hline, \hdashline, | ||||||
* \underline, \overline, and the borders of \fbox, \boxed, and | ||||||
* \fcolorbox. | ||||||
*/ | ||||||
minRuleThickness?: number | undefined; | ||||||
/** | ||||||
* If `true`, `\color` will work like LaTeX's `\textcolor` | ||||||
* and takes 2 arguments | ||||||
* | ||||||
* If `false`, `\color` will work like LaTeX's `\color` | ||||||
* and takes 1 argument | ||||||
* | ||||||
* In both cases, `\textcolor` works as in LaTeX | ||||||
* | ||||||
* @default false | ||||||
*/ | ||||||
colorIsTextColor?: boolean | undefined; | ||||||
/** | ||||||
* All user-specified sizes will be caped to `maxSize` ems | ||||||
* | ||||||
* If set to Infinity, users can make elements and space | ||||||
* arbitrarily large | ||||||
* | ||||||
* @default Infinity | ||||||
*/ | ||||||
maxSize?: number | undefined; | ||||||
/** | ||||||
* Limit the number of macro expansions to specified number | ||||||
* | ||||||
* If set to `Infinity`, marco expander will try to fully expand | ||||||
* as in LaTex | ||||||
* | ||||||
* @default 1000 | ||||||
*/ | ||||||
maxExpand?: number | undefined; | ||||||
/** | ||||||
* If `false` or `"ignore"`, allow features that make | ||||||
* writing in LaTex convenient but not supported by LaTex | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This clear typo makes me wonder whether we should instead copy descriptions from the official documentation, which are likely more precise. |
||||||
* | ||||||
* If `true` or `"error"`, throw an error for such transgressions | ||||||
* | ||||||
* If `"warn"`, warn about behavior via `console.warn` | ||||||
* | ||||||
* @default "warn" | ||||||
*/ | ||||||
strict?: boolean | string | Function | undefined; | ||||||
/** | ||||||
* If `false` (do not trust input), prevent any commands that could enable adverse behavior, rendering them instead in errorColor. | ||||||
* | ||||||
* If `true` (trust input), allow all such commands. | ||||||
* | ||||||
* @default false | ||||||
*/ | ||||||
trust?: boolean | ((context: TrustContext) => boolean) | undefined; | ||||||
/** | ||||||
* Place KaTeX code in the global group. | ||||||
* | ||||||
* @default false | ||||||
*/ | ||||||
globalGroup?: boolean | undefined; | ||||||
} | ||||||
|
||||||
/** | ||||||
* KaTeX error, usually during parsing. | ||||||
*/ | ||||||
export class ParseError implements Error { | ||||||
constructor(message: string, lexer: any, position: number); | ||||||
|
||||||
name: string; | ||||||
message: string; | ||||||
position: number; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Renders a TeX expression into the specified DOM element | ||||||
* @param tex A TeX expression | ||||||
* @param element The DOM element to render into | ||||||
* @param options KaTeX options | ||||||
*/ | ||||||
export function render(tex: string, element: HTMLElement, options?: KatexOptions): void; | ||||||
|
||||||
/** | ||||||
* Renders a TeX expression into an HTML string | ||||||
* @param tex A TeX expression | ||||||
* @param options KaTeX options | ||||||
*/ | ||||||
export function renderToString(tex: string, options?: KatexOptions): string; | ||||||
|
||||||
export as namespace katex; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.