This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

20
node_modules/remark-emoji/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2016 rhysd
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.

102
node_modules/remark-emoji/README.md generated vendored Normal file
View File

@@ -0,0 +1,102 @@
remark-emoji
============
[![CI][ci-badge]][ci]
[![npm][npm-badge]][npm]
[remark-emoji][npm] is a [remark](https://github.com/remarkjs/remark) plugin to replace `:emoji:` to real UTF-8
emojis in text. Accessibility support and Emoticon support are optionally available.
## Demo
You can find a demo in the following [Codesandbox](https://codesandbox.io/s/remark-emoji-example-osvyi).
## Usage
```
remark().use(emoji [, options]);
```
```javascript
import {remark} from 'remark';
import emoji from 'remark-emoji';
const doc = 'Emojis in this text will be replaced: :dog: :+1:';
const processor = remark().use(emoji);
const file = await processor.process(doc);
console.log(String(file));
// => Emojis in this text will be replaced: 🐶 👍
```
Note that this package is [ESM only][esm-only] from v3.0.0 since remark packages migrated to ESM.
## Options
### `options.accessible`
Setting to `true` makes the converted emoji text accessible with `role` and `aria-label` attributes. Each emoji
text is wrapped with `<span>` element. Note that `role` attribute is not allowed by default. Please add it to
the sanitization schema used by remark's HTML transformer.
For example,
```javascript
import {remark} from 'remark';
import toHtml from 'remark-html';
import {defaultSchema} from 'hast-util-sanitize'
import emoji from 'remark-emoji';
// Allow using `role` attribute in transformed HTML document
const schema = structuredClone(defaultSchema);
if ('span' in schema.attributes) {
schema.attributes.span.push('role');
} else {
schema.attributes.span = ['role'];
}
const processor = remark()
.use(emoji, { accessible: true })
.use(toHtml, { sanitize: schema });
const file = await processor.process('Hello :dog:!');
console.log(String(file));
```
yields
```html
Hello <span role="img" aria-label="dog emoji">🐶</span>!
```
Default value is `false`.
### `options.padSpaceAfter`
Setting to `true` means that an extra whitespace is added after emoji.
This is useful when browser handle emojis with half character length and following character is hidden.
Default value is `false`.
### `options.emoticon`
Setting to `true` means that [emoticon](https://www.npmjs.com/package/emoticon) shortcodes are supported (e.g. :-)
will be replaced by 😃). Default value is `false`.
## TypeScript support
remark-emoji package contains [TypeScript](https://www.typescriptlang.org/) type definitions. The package is ready
for use with TypeScript.
Note that the legacy `node` (or `node10`) resolution at [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution)
is not available since it enforces CommonJS module resolution and this package is ESM only. Please use `node16`,
`bundler`, or `nodenext` to enable ESM module resolution.
## License
Distributed under [the MIT License](LICENSE).
[ci-badge]: https://github.com/rhysd/remark-emoji/workflows/CI/badge.svg?branch=master&event=push
[ci]: https://github.com/rhysd/remark-emoji/actions?query=workflow%3ACI
[npm-badge]: https://badge.fury.io/js/remark-emoji.svg
[npm]: https://www.npmjs.com/package/remark-emoji
[esm-only]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

85
node_modules/remark-emoji/index.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
import { get as getEmoji } from 'node-emoji';
import { emoticon } from 'emoticon';
import { findAndReplace } from 'mdast-util-find-and-replace';
const RE_EMOJI = /:\+1:|:-1:|:[\w-]+:/g;
const RE_SHORT = /[$@|*'",;.=:\-)([\]\\/<>038BOopPsSdDxXzZ]{2,5}/g;
const RE_PUNCT = /(?:_|-(?!1))/g;
const DEFAULT_SETTINGS = {
padSpaceAfter: false,
emoticon: false,
accessible: false,
};
export default function plugin(options) {
const settings = Object.assign({}, DEFAULT_SETTINGS, options);
const pad = !!settings.padSpaceAfter;
const emoticonEnable = !!settings.emoticon;
const accessible = !!settings.accessible;
function aria(text, label) {
// Creating HTML node in Markdown node is undocumented.
// https://github.com/syntax-tree/mdast-util-math/blob/e70bb824dc70f5423324b31b0b68581cf6698fe8/index.js#L44-L55
return {
type: 'text',
meta: null,
value: text,
data: {
hName: 'span',
hProperties: {
role: 'img',
ariaLabel: label,
},
hChildren: [{ type: 'text', value: text }],
},
};
}
function replaceEmoticon(match) {
// find emoji by shortcode - full match or with-out last char as it could be from text e.g. :-),
const iconFull = emoticon.find(e => e.emoticons.includes(match)); // full match
const iconPart = emoticon.find(e => e.emoticons.includes(match.slice(0, -1))); // second search pattern
const icon = iconFull || iconPart;
if (!icon) {
return false;
}
const trimmedChar = !iconFull && iconPart ? match.slice(-1) : '';
const addPad = pad ? ' ' : '';
const replaced = icon.emoji + addPad + trimmedChar;
if (accessible) {
return aria(replaced, icon.name + ' emoticon');
}
return replaced;
}
function replaceEmoji(match) {
let got = getEmoji(match);
if (typeof got === 'undefined') {
return false;
}
if (pad) {
got = got + ' ';
}
if (accessible) {
const label = match.slice(1, -1).replace(RE_PUNCT, ' ') + ' emoji';
return aria(got, label);
}
return got;
}
const replacers = [[RE_EMOJI, replaceEmoji]];
if (emoticonEnable) {
replacers.push([RE_SHORT, replaceEmoticon]);
}
function transformer(tree) {
findAndReplace(tree, replacers);
}
return transformer;
}

71
node_modules/remark-emoji/package.json generated vendored Normal file
View File

@@ -0,0 +1,71 @@
{
"name": "remark-emoji",
"version": "4.0.1",
"type": "module",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"description": "Emoji transformer plugin for Remark",
"exports": {
".": {
"import": {
"types": "./types/index.d.ts",
"default": "./index.js"
}
}
},
"scripts": {
"eslint": "eslint .",
"prettier": "prettier -c '**/*.js' '**/*.ts'",
"lint": "concurrently -c auto npm:eslint npm:prettier npm:dtslint",
"dtslint": "dtslint types",
"mocha": "mocha --color test.js",
"format": "prettier -w '**/*.js' '**/*.ts'",
"test": "concurrently -c auto npm:mocha npm:dtslint"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rhysd/remark-emoji.git"
},
"keywords": [
"markdown",
"emoji",
"remark",
"plugin"
],
"types": "types/index.d.ts",
"files": [
"types/index.d.ts",
"index.js"
],
"author": "rhysd <lin90162@yahoo.co.jp>",
"license": "MIT",
"bugs": {
"url": "https://github.com/rhysd/remark-emoji/issues"
},
"homepage": "https://github.com/rhysd/remark-emoji#readme",
"devDependencies": {
"concurrently": "^8.2.2",
"dtslint": "^4.2.1",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-mocha": "^10.2.0",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-security": "^1.7.1",
"mocha": "^10.2.0",
"prettier": "^3.0.3",
"remark": "^15.0.1",
"remark-autolink-headings": "^7.0.1",
"remark-github": "^12.0.0",
"remark-html": "^16.0.1",
"remark-slug": "^7.0.1",
"typescript": "^5.2.2"
},
"dependencies": {
"@types/mdast": "^4.0.2",
"emoticon": "^4.0.1",
"mdast-util-find-and-replace": "^3.0.1",
"node-emoji": "^2.1.0",
"unified": "^11.0.4"
}
}

29
node_modules/remark-emoji/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,29 @@
import type { Plugin } from 'unified';
import type { Root } from 'mdast';
export interface RemarkEmojiOptions {
/**
* Makes converted emoji and emoticon texts accessible by wrapping them with
* `span` element setting `role` and `aria-label` attributes.
*
* @defaultValue false
*/
accessible?: boolean;
/**
* Adds an extra whitespace after emoji.
* Useful when browser handle emojis with half character length and
* the following character is hidden.
*
* @defaultValue false
*/
padSpaceAfter?: boolean;
/**
* Whether to support emoticon shortcodes (e.g. :-) will be replaced by 😃)
*
* @defaultValue false
*/
emoticon?: boolean;
}
declare const plugin: Plugin<[(RemarkEmojiOptions | null | undefined)?], Root>;
export default plugin;