escape-latex

WebJar for escape-latex

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

escape-latex
Последняя версия

Последняя версия

1.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

escape-latex
WebJar for escape-latex
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/dangmai/escape-latex

Скачать escape-latex

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/escape-latex/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>escape-latex</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/escape-latex/
implementation 'org.webjars.npm:escape-latex:1.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/escape-latex/
implementation ("org.webjars.npm:escape-latex:1.2.0")
'org.webjars.npm:escape-latex:jar:1.2.0'
<dependency org="org.webjars.npm" name="escape-latex" rev="1.2.0">
  <artifact name="escape-latex" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='escape-latex', version='1.2.0')
)
libraryDependencies += "org.webjars.npm" % "escape-latex" % "1.2.0"
[org.webjars.npm/escape-latex "1.2.0"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

escape-latex

Build Status codecov

Escape LaTeX special characters with Javascript in NodeJS (>= 10.x) environment.

Usage

npm install escape-latex
var lescape = require('escape-latex');
lescape("String to be escaped here #yolo");

API

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

Testing

npm test

Notes

  • If you are updating from 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.

License

MIT

Версии библиотеки

Версия
1.2.0
1.0.3