remark-cjk-friendly 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +149 -0
- package/dist/index.cjs +41 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2024 Tatsunori Uchino, and authors and contributors of original packages
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# remark-cjk-friendly
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly) [](https://npmjs.com/package/remark-cjk-friendly)
|
|
4
|
+
|
|
5
|
+
A [remark](https://github.com/remarkjs/remark) plugin to make Markdown emphasis (`**`) in CommonMark compatible with Chinese, Japanese, and Korean (CJK).
|
|
6
|
+
|
|
7
|
+
<span lang="ja">CommonMarkの強調記号(`**`)を日本語・中国語・韓国語にきちんと対応させるための[remark](https://github.com/remarkjs/remark)プラグイン</span>
|
|
8
|
+
|
|
9
|
+
<span lang="zh-Hans-CN">一个 [remark](https://github.com/remarkjs/remark) 插件,用于使 CommonMark 的强调标记(`**`)能够正确支持中文、日语和韩语文本。</span>
|
|
10
|
+
|
|
11
|
+
<span lang="ko">CommonMark의 강조 표시(`**`) 를 한국어, 중국어, 일본어와 호환되도록 만드는 [remark](https://github.com/remarkjs/remark) 플러그인</span>
|
|
12
|
+
|
|
13
|
+
## Problem / <span lang="ja">問題</span> / <span lang="zh-Hans-CN">问题</span> / <span lang="ko">문제점</span>
|
|
14
|
+
|
|
15
|
+
CommonMark has a problem that the following emphasis marks `**` are not recognized as emphasis marks in Japanese, Chinese, and Korean.
|
|
16
|
+
|
|
17
|
+
<span lang="ja">CommonMarkには、日本語・中国語・韓国語内の次のような強調記号(`**`)が強調記号として認識されない問題があります。</span>
|
|
18
|
+
|
|
19
|
+
<span lang="zh-Hans-CN">CommonMark存在以下问题:在中文、日语和韩语文本中,强调标记`**`不会被识别为强调标记。</span>
|
|
20
|
+
|
|
21
|
+
<span lang="ko">CommonMark는 일본어와 중국어에서 다음과 같은 강조 표시 `**`가 강조 표시로 인식되지 않는 문제가 있습니다.</span>
|
|
22
|
+
|
|
23
|
+
```md
|
|
24
|
+
**このアスタリスクは強調記号として認識されず、そのまま表示されます。**この文のせいで。
|
|
25
|
+
|
|
26
|
+
**该星号不会被识别,而是直接显示。**这是因为它没有被识别为强调符号。
|
|
27
|
+
|
|
28
|
+
**이 별표는 강조 표시로 인식되지 않고 그대로 표시됩니다(이 괄호 때문에)**이 문장 때문에.
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This problem occurs because the character just inside the `**` is a (Japanese or Chinese) punctuation mark (。) or parenthesis and the character just outside is not a space or punctuation mark.
|
|
32
|
+
|
|
33
|
+
<span lang="ja">これが起こった原因は、終了側の`**`のすぐ内側が約物(。やカッコ)、かつ外側が約物や空白以外の文字であるためです。</span>
|
|
34
|
+
|
|
35
|
+
<span lang="zh-Hans-CN">这个问题是因为在`**`的结束部分,内侧字符是标点符号(。)或括号,而外侧字符不是空格或标点符号。</span>
|
|
36
|
+
|
|
37
|
+
<span lang="ko">이 문제는 `**` 바로 안쪽의 문자가 (일본어나 중국어) 문장 부호(。) 또는 괄호이고 바깥쪽 문자가 공백이나 문장 부호가 아니기 때문에 발생합니다.</span>
|
|
38
|
+
|
|
39
|
+
Of course, not only the end side but also the start side has the same issue.
|
|
40
|
+
|
|
41
|
+
<span lang="ja">もちろん終了側だけでなく、開始側も同様の問題が存在します。</span>
|
|
42
|
+
|
|
43
|
+
<span lang="zh-Hans-CN">当然,不仅是结束侧,开始侧也存在同样的问题。</span>
|
|
44
|
+
|
|
45
|
+
<span lang="ko">물론 끝나는 부분뿐만 아니라 시작하는 부분에서도 동일한 문제가 있습니다.</span>
|
|
46
|
+
|
|
47
|
+
CommonMark issue: https://github.com/commonmark/commonmark-spec/issues/650
|
|
48
|
+
|
|
49
|
+
## Runtime Requirements / <span lang="ja">実行環境の要件</span> / <span lang="zh-Hans-CN">运行环境要求</span> / <span lang="ko">업데이트 전략</span>
|
|
50
|
+
|
|
51
|
+
This package uses the [`v` flag of the regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets) introduced in ES2024 to determine whether the character is an emoji or not.
|
|
52
|
+
|
|
53
|
+
<span lang="ja">本パッケージは文字が絵文字かどうかを判定するために、ES2024で導入された[正規表現の`v`フラグ](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets)を使用しています。</span>
|
|
54
|
+
|
|
55
|
+
<span lang="zh-CN">本包使用 ES2024 引入的[`v` 标志](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets) 来判断字符是否为 emoji。</span>
|
|
56
|
+
|
|
57
|
+
<span lang="ko">이 패키지는 ES2024에서 도입된 [`v` 플래그](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets)를 사용하여 문자가 이모지인지 여부를 판단합니다.</span>
|
|
58
|
+
|
|
59
|
+
It makes this package compatible only with relatively recent browsers and Node.js:
|
|
60
|
+
|
|
61
|
+
<span lang="ja">このため、本パッケージは、次のような比較的新しいブラウザやNode.jsでしか動作しません。</span>
|
|
62
|
+
|
|
63
|
+
<span lang="zh-CN">因此,本包只兼容比较新的浏览器和 Node.js:</span>
|
|
64
|
+
|
|
65
|
+
<span lang="ko">따라서, 이 패키지는 비교적 최신 브라우저와 Node.js에서만 작동합니다.</span>
|
|
66
|
+
|
|
67
|
+
- Chrome / Edge 112 or later
|
|
68
|
+
- Firefox 116 or later
|
|
69
|
+
- Safari 17 or later
|
|
70
|
+
- Node.js 20 or later
|
|
71
|
+
|
|
72
|
+
## Installation / <span lang="ja">インストール</span> / <span lang="zh-Hans-CN">安装</span> / <span lang="ko">설치</span>
|
|
73
|
+
|
|
74
|
+
Install `remark-cjk-friendly` via [npm](https://www.npmjs.com/):
|
|
75
|
+
|
|
76
|
+
<span lang="ja">`remark-cjk-friendly`を[npm](https://www.npmjs.com/)でインストールしてください。</span>
|
|
77
|
+
|
|
78
|
+
<span lang="zh-Hans-CN">通过 [npm](https://www.npmjs.com/) 安装 `remark-cjk-friendly`。</span>
|
|
79
|
+
|
|
80
|
+
<span lang="ko">`remark-cjk-friendly`를 [npm](https://www.npmjs.com/)으로 설치하세요.</span>
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install remark-cjk-friendly
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If you use another package manager, please replace `npm install` with the command of the package manager you use (e.g. `pnpm add` or `yarn add`).
|
|
87
|
+
|
|
88
|
+
<span lang="ja">npm以外のパッケージマネージャを使う場合は、`npm install`を当該パッケージマネージャのコマンド(例:`pnpm add`・`yarn add`)に置き換えてください。</span>
|
|
89
|
+
|
|
90
|
+
<span lang="zh-Hans-CN">如果使用其他包管理器,请将 `npm install` 替换为当时包管理器的命令(例如:`pnpm add`、`yarn add`)。</span>
|
|
91
|
+
|
|
92
|
+
<span lang="ko">다른 패키지 매니저를 사용하는 경우 `npm install`을 해당 패키지 매니저의 명령어(예: `pnpm add`, `yarn add`)로 바꾸어 주세요.</span>
|
|
93
|
+
|
|
94
|
+
## Usage / <span lang="ja">使い方</span> / <span lang="zh-Hans-CN">用法</span> / <span lang="ko">사용법</span>
|
|
95
|
+
|
|
96
|
+
Import `remark` and `remark-cjk-friendly`, and use the plugin as follows:
|
|
97
|
+
|
|
98
|
+
<span lang="ja">`remark`と`remark-cjk-friendly`をインポートし、次のようにプラグインを使用してください。</span>
|
|
99
|
+
|
|
100
|
+
<span lang="zh-Hans-CN">通过 `remark` 和 `remark-cjk-friendly` 导入,然后使用插件如下:</span>
|
|
101
|
+
|
|
102
|
+
<span lang="ko">`remark`와 `remark-cjk-friendly`를 임포트하고 다음과 같이 플러그인을 사용하세요.</span>
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import rehypeStringify from "rehype-stringify";
|
|
106
|
+
import remarkCjkFriendly from "remark-cjk-friendly";
|
|
107
|
+
import remarkGfm from "remark-gfm";
|
|
108
|
+
import remarkParse from "remark-parse";
|
|
109
|
+
import remarkRehype from "remark-rehype";
|
|
110
|
+
import { unified } from "unified";
|
|
111
|
+
|
|
112
|
+
// e.g. in the case that you want to enable GFM and obtain HTML output
|
|
113
|
+
const processor = unified()
|
|
114
|
+
.use(remarkParse)
|
|
115
|
+
.use(remarkGfm)
|
|
116
|
+
.use(remarkCjkFriendly)
|
|
117
|
+
.use(remarkRehype)
|
|
118
|
+
.use(rehypeStringify);
|
|
119
|
+
|
|
120
|
+
const htmlResult = (await processor.process(markdownString)).toString();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Specification / <span lang="ja">規格書</span> / <span lang="zh-Hans-CN">规范</span> / <span lang="ko">규정서</span>
|
|
124
|
+
|
|
125
|
+
https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md (English)
|
|
126
|
+
|
|
127
|
+
## Contributing / <span lang="ja">貢献</span> / <span lang="zh-Hans-CN">贡献</span> / <span lang="ko">기여</span>
|
|
128
|
+
|
|
129
|
+
### Setup
|
|
130
|
+
|
|
131
|
+
Install the dependencies:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm install
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Get Started
|
|
138
|
+
|
|
139
|
+
Build the library:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
pnpm build
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Build the library in watch mode:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
pnpm dev
|
|
149
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.r = function(exports1) {
|
|
18
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
19
|
+
value: 'Module'
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
22
|
+
value: true
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
var __webpack_exports__ = {};
|
|
27
|
+
__webpack_require__.r(__webpack_exports__);
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
default: ()=>remarkCjkFriendly
|
|
30
|
+
});
|
|
31
|
+
const external_micromark_extension_cjk_friendly_namespaceObject = require("micromark-extension-cjk-friendly");
|
|
32
|
+
function remarkCjkFriendly() {
|
|
33
|
+
const data = this.data();
|
|
34
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
35
|
+
micromarkExtensions.push((0, external_micromark_extension_cjk_friendly_namespaceObject.cjkFriendlyExtension)());
|
|
36
|
+
}
|
|
37
|
+
var __webpack_export_target__ = exports;
|
|
38
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
39
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
40
|
+
value: true
|
|
41
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_1c72e10b__ from "micromark-extension-cjk-friendly";
|
|
2
|
+
function remarkCjkFriendly() {
|
|
3
|
+
const data = this.data();
|
|
4
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
5
|
+
micromarkExtensions.push((0, __WEBPACK_EXTERNAL_MODULE_micromark_extension_cjk_friendly_1c72e10b__.cjkFriendlyExtension)());
|
|
6
|
+
}
|
|
7
|
+
export { remarkCjkFriendly as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "remark-cjk-friendly",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"module-sync": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"url": "https://github.com/tats-u/markdown-cjk-friendly"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Tatsunori Uchino <tats.u@live.jp> (https://github.com/tats-u)",
|
|
26
|
+
"bugs": "https://github.com/tats-u/markdown-cjk-friendly/issues",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"remark-plugin",
|
|
29
|
+
"remark",
|
|
30
|
+
"markdown",
|
|
31
|
+
"japanese",
|
|
32
|
+
"chinese",
|
|
33
|
+
"korean",
|
|
34
|
+
"cjk",
|
|
35
|
+
"mdast",
|
|
36
|
+
"unified"
|
|
37
|
+
],
|
|
38
|
+
"description": "remark plugin to make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK)",
|
|
39
|
+
"sideEffects": false,
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"micromark-extension-cjk-friendly": "<2.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@rslib/core": "^0.3.1",
|
|
45
|
+
"rehype-stringify": "10.0.1",
|
|
46
|
+
"remark": "^15.0.1",
|
|
47
|
+
"remark-gfm": "^4.0.0",
|
|
48
|
+
"remark-parse": "^11.0.0",
|
|
49
|
+
"remark-rehype": "^11.1.1",
|
|
50
|
+
"unified": "^11.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@types/mdast": "^4.0.0",
|
|
54
|
+
"unified": "^11.0.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@types/mdast": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=20"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "rslib build",
|
|
66
|
+
"dev": "rslib build --watch",
|
|
67
|
+
"test": "vitest --run",
|
|
68
|
+
"test:up": "vitest -u",
|
|
69
|
+
"test:watch": "vitest watch",
|
|
70
|
+
"lint:type": "tsc --noEmit"
|
|
71
|
+
}
|
|
72
|
+
}
|