feat:node-modules

This commit is contained in:
houjunxiang
2025-11-24 10:26:18 +08:00
parent 753766893b
commit 8a3e48d856
8825 changed files with 567399 additions and 1 deletions

18
node_modules/escape-latex/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,18 @@
Copyright (c) 2012 Dang Mai
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

75
node_modules/escape-latex/README.md generated vendored Normal file
View File

@@ -0,0 +1,75 @@
# escape-latex
[![Greenkeeper badge](https://badges.greenkeeper.io/dangmai/escape-latex.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/dangmai/escape-latex.png)](https://travis-ci.org/dangmai/escape-latex)
Escape LaTeX special characters with Javascript in NodeJS (>= 4.x) environment.
## Usage
```javascript
npm install escape-latex
var lescape = require('escape-latex');
lescape("String to be escaped here #yolo");
```
## API
```javascript
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:
```javascript
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:
```javascript
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

80
node_modules/escape-latex/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
"use strict";
// Map the characters to escape to their escaped values. The list is derived
// from http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var defaultEscapes = {
"{": "\\{",
"}": "\\}",
"\\": "\\textbackslash{}",
"#": "\\#",
$: "\\$",
"%": "\\%",
"&": "\\&",
"^": "\\textasciicircum{}",
_: "\\_",
"~": "\\textasciitilde{}"
};
var formatEscapes = {
"\u2013": "\\--",
"\u2014": "\\---",
" ": "~",
"\t": "\\qquad{}",
"\r\n": "\\newline{}",
"\n": "\\newline{}"
};
var defaultEscapeMapFn = function defaultEscapeMapFn(defaultEscapes, formatEscapes) {
return _extends({}, defaultEscapes, formatEscapes);
};
/**
* Escape a string to be used in LaTeX documents.
* @param {string} str the string to be escaped.
* @param {boolean} params.preserveFormatting whether formatting escapes should
* be performed (default: false).
* @param {function} params.escapeMapFn the function to modify the escape maps.
* @return {string} the escaped string, ready to be used in LaTeX.
*/
module.exports = function (str) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$preserveFormatti = _ref.preserveFormatting,
preserveFormatting = _ref$preserveFormatti === undefined ? false : _ref$preserveFormatti,
_ref$escapeMapFn = _ref.escapeMapFn,
escapeMapFn = _ref$escapeMapFn === undefined ? defaultEscapeMapFn : _ref$escapeMapFn;
var runningStr = String(str);
var result = "";
var escapes = escapeMapFn(_extends({}, defaultEscapes), preserveFormatting ? _extends({}, formatEscapes) : {});
var escapeKeys = Object.keys(escapes); // as it is reused later on
// Algorithm: Go through the string character by character, if it matches
// with one of the special characters then we'll replace it with the escaped
// version.
var _loop = function _loop() {
var specialCharFound = false;
escapeKeys.forEach(function (key, index) {
if (specialCharFound) {
return;
}
if (runningStr.length >= key.length && runningStr.slice(0, key.length) === key) {
result += escapes[escapeKeys[index]];
runningStr = runningStr.slice(key.length, runningStr.length);
specialCharFound = true;
}
});
if (!specialCharFound) {
result += runningStr.slice(0, 1);
runningStr = runningStr.slice(1, runningStr.length);
}
};
while (runningStr) {
_loop();
}
return result;
};

55
node_modules/escape-latex/package.json generated vendored Normal file
View File

@@ -0,0 +1,55 @@
{
"name": "escape-latex",
"version": "1.2.0",
"description": "Escape LaTeX special characters with Javascript",
"main": "./dist/index.js",
"files": ["dist"],
"scripts": {
"test": "mocha --require babel-core/register -u tdd ./src/**/*.test.js",
"preversion": "npm test && npm run build",
"postversion": "git push && git push --tags",
"precommit": "npm run lint && lint-staged",
"prettier": "prettier --write ./src/**/*.js",
"lint": "eslint ./src",
"init": "mkdir dist",
"clean": "rm -rf dist",
"prebuild": "npm run clean && npm run init",
"build": "babel ./src -d ./dist --ignore index.test.js"
},
"lint-staged": {
"*.{js,json,css,md}": ["npm run prettier", "git add"]
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 8
},
"extends": ["eslint:recommended", "google", "prettier"],
"env": {
"node": "true"
}
},
"prettier": {
"trailingComma": "all"
},
"repository": {
"type": "git",
"url": "https://github.com/dangmai/escape-latex"
},
"keywords": ["latex", "escape"],
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-env": "^1.6.1",
"chai": "^4.1.2",
"eslint": "^5.0.1",
"eslint-config-google": "^0.9.1",
"eslint-config-prettier": "^3.0.1",
"husky": "^0.14.3",
"lint-staged": "^7.0.5",
"mocha": "^5.0.0",
"prettier": "^1.9.2"
},
"author": "Dang Mai",
"license": "MIT"
}