New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mathlifier

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathlifier - npm Package Compare versions

Comparing version

to
1.3.0

lib/display.d.ts

83

lib/index.d.ts

@@ -200,2 +200,40 @@ /**

/**
* Renders alignat environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param pairs number of r/l column pairs
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{alignat} ... \\end{alignat}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
declare function alignat(x: string, pairs: number, options?: KatexOptionsDisplay): string;
/**
* Renders alignat* environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param pairs number of r/l column pairs
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{alignat*} ... \\end{alignat*}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
declare function alignatStar(x: string, pairs: number, options?: KatexOptionsDisplay): string;
/**
* Renders gather environment in displayed mode

@@ -236,6 +274,49 @@ *

declare function gatherStar(x: string, options?: KatexOptionsDisplay): string;
/**
* Renders equation environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{equation} ... \\end{equation}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
declare function equation(x: string, options?: KatexOptionsDisplay): string;
/**
* Renders equation* environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{equation*} ... \\end{equation*}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
declare function equationStar(x: string, options?: KatexOptionsDisplay): string;
declare const eqn: typeof equation;
declare const eqnStar: typeof equationStar;
declare const linebreak = "<br>";
declare const newline = "<br>";
declare function bold(x: string): string;
declare const strong: typeof bold;
declare function em(x: string): string;
declare const emph: typeof em;
declare const newParagraph = "<p>";
export { align, alignStar, bold, display, gather, gatherStar, linebreak, math };
export { align, alignStar, alignat, alignatStar, bold, display, em, emph, eqn, eqnStar, equation, equationStar, gather, gatherStar, linebreak, math, newParagraph, newline, strong };

4

lib/types/index.d.ts
export { math } from './math';
export { display } from './display';
export { align, alignStar, gather, gatherStar } from './mathEnvironments';
export { linebreak, bold } from './typesettingUtils';
export { align, alignStar, gather, gatherStar, equation, eqn, equationStar, eqnStar, alignat, alignatStar, } from './mathEnvironments';
export { linebreak, newline, bold, strong, emph, em, newParagraph } from './typesettingUtils';

@@ -39,2 +39,40 @@ import { type KatexOptionsDisplay } from './display';

/**
* Renders alignat environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param pairs number of r/l column pairs
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{alignat} ... \\end{alignat}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
export declare function alignat(x: string, pairs: number, options?: KatexOptionsDisplay): string;
/**
* Renders alignat* environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param pairs number of r/l column pairs
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{alignat*} ... \\end{alignat*}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
export declare function alignatStar(x: string, pairs: number, options?: KatexOptionsDisplay): string;
/**
* Renders gather environment in displayed mode

@@ -75,1 +113,39 @@ *

export declare function gatherStar(x: string, options?: KatexOptionsDisplay): string;
/**
* Renders equation environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{equation} ... \\end{equation}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
export declare function equation(x: string, options?: KatexOptionsDisplay): string;
/**
* Renders equation* environment in displayed mode
*
* Takes a TeX expression and outputs a HTML string for the rendered math in displayed mode
*
* @param x TeX expression to be rendered
* @param options defaults to `{overflowAuto: true, throwOnError: false}`.
* overflowAuto is a custom option where the default `overflowAuto===true` wraps the generated HTML in a container with `style="overflow-x:auto;"`
* All KaTeX options are supported, and with the exception of `throwOnError` and `displayMode` are left as default
*
* @returns HTML string generated by KaTeX representing displayed math
*
* With default options, is equivalent to
* wrapping x with `\\begin{equation*} ... \\end{equation*}`, calling
* `katex.renderToString(x, {throwOnError: false, displayMode: true})
* and wrapping it in a container with `style="overflow-x:auto;"`
*/
export declare function equationStar(x: string, options?: KatexOptionsDisplay): string;
export declare const eqn: typeof equation;
export declare const eqnStar: typeof equationStar;
export declare const linebreak = "<br>";
export declare const newline = "<br>";
export declare function bold(x: string): string;
export declare const strong: typeof bold;
export declare function em(x: string): string;
export declare const emph: typeof em;
export declare const newParagraph = "<p>";
{
"name": "mathlifier",
"version": "1.2.2",
"version": "1.3.0",
"description": "A KaTeX renderToString wrapper",

@@ -52,18 +52,18 @@ "source": "src/index.ts",

"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.1",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-terser": "^0.3.0",
"@rollup/plugin-typescript": "^11.0.0",
"@types/katex": "^0.14.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"c8": "^7.10.0",
"eslint": "^8.0.1",
"prettier": "^2.4.1",
"rollup": "^2.69.0",
"rollup-plugin-dts": "^4.2.0",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.3.1",
"tsm": "^2.2.2",
"typescript": "^4.4.4",
"uvu": "^0.5.2"
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"c8": "^7.12.0",
"eslint": "^8.32.0",
"prettier": "^2.8.3",
"rollup": "^3.10.0",
"rollup-plugin-dts": "^5.1.0",
"tslib": "^2.4.1",
"tsm": "^2.3.0",
"typescript": "^4.9.4",
"uvu": "^0.5.6"
},

@@ -70,0 +70,0 @@ "dependencies": {

@@ -6,3 +6,3 @@ # Mathlifier

[![mathlifier npm version](https://img.shields.io/npm/v/mathlifier)](https://github.com/kelvinsjk/mathlified/tree/main/packages/mathlifier)
[![mathlifier.min.js size](https://img.shields.io/bundlephobia/minzip/mathlifier)](https://github.com/kelvinsjk/mathlified/tree/main/packages/mathlifier)
[![mathlifier minzip size](https://img.shields.io/bundlephobia/minzip/mathlifier)](https://github.com/kelvinsjk/mathlified/tree/main/packages/mathlifier)

@@ -22,8 +22,12 @@ ---

> While KaTeX sets throwOnError to `true` by default, we have opted to set it to false.
> While KaTeX sets throwOnError to `true` by default, we have opted to set it to false
We think that this facilitates quicker debugging (especially useful when hot module reloading (HMR) is active).
### Opinion 2: No line break in inline math
> By default, we wrap all inputs with braces to prevent line-breaking.
> By default, we wrap all inputs with braces to prevent automatic line-breaking.
Disable this with an [option](#custom-mathlifier-options)
### Opinion 3: Displayed math with overflow-x: auto

@@ -35,2 +39,4 @@

Disable this with an [option](#custom-mathlifier-options)
## Installing Mathlifier

@@ -42,3 +48,3 @@

## Using Mathlified
## Using Mathlifier

@@ -63,4 +69,4 @@ ```js

rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.css"
integrity="sha384-MlJdn/WNKDGXveldHDdyRP1R4CTHr3FeuDNfhsLPYrq2t0UBkUdK2jyTnXPEK1NQ"
href="https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css"
integrity="sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0"
crossorigin="anonymous"

@@ -70,8 +76,8 @@ />

## Custom Mathlified options
## Custom Mathlifier options
We can disable the default behavior (opinions 2 and 3 above) of Mathlified vs regular KaTeX
We can disable the default behavior (opinions 2 and 3 above) of Mathlifier vs regular KaTeX
```js
// example of Mathlified options
// example of Mathlifier options
const allowBreak = math('e^{i\\pi} = -1', { wrap: true });

@@ -78,0 +84,0 @@ const noContainer = display('\\sum_{r=1}^n = \\frac{n(n+1)}{2}', { overflowAuto: false });

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet