![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
escape-latex
Advanced tools
Escape LaTeX special characters with Javascript in NodeJS (>= 4.x) environment.
npm install escape-latex
var lescape = require('escape-latex');
lescape("String to be escaped here #yolo");
lescape((input: String), {
preserveFormatting: Boolean,
escapeMapFn: Function,
});
By default,
escape-latex
only escapes characters that would result in malformed LaTeX.
These characters include # $ % & \ ^ _ { }
.
This means that the final LaTeX output might not look the same as your input Javascript string. For example, multiple spaces are kept as-is, which may be truncated to 1 space by your LaTeX software.
If you want the final output string to be as similar to your input Javascript string as possible,
you can set the preserveFormatting
param to true
, like so:
lescape("Hello World", { preserveFormatting: true });
// Hello~~~World
Which will be converted to three non-breaking spaces by your LaTeX software.
The list of format characters that are escaped include space, \t (tab), – (en-dash), — (em-dash)
.
There is also the param escapeMapFn
to modify the mapping of escaped characters,
so you can add/modify/remove your own escapes if necessary.
It accepts a callback function that takes in the default character escapes and the formatting escapes as parameters, and returns a complete escape mapping. Here's an example:
lescape("Hello World", {
preseveFormatting: true,
escapeMapFn: function(defaultEscapes, formattingEscapes) {
formattingEscapes[" "] = "\\\\";
return Object.assign({}, defaultEscapes, formattingEscapes);
},
});
// Hello\\\\\\world
npm test
escape-latex < 1.0.0
,
the en-dash
and em-dash
are no longer escaped by default.
Please use preserveFormatting
to turn them on if necessary.MIT
FAQs
Escape LaTeX special characters with Javascript
The npm package escape-latex receives a total of 888,970 weekly downloads. As such, escape-latex popularity was classified as popular.
We found that escape-latex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.