remark-cjk-friendly 2.1.0 → 2.2.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/README.md CHANGED
@@ -170,13 +170,13 @@ const processor = unified()
170
170
  const htmlResult = (await processor.process(markdownString)).toString();
171
171
  ```
172
172
 
173
- This plugin also wires the reverse path for `remark-stringify` / `mdast-util-to-markdown`, so CJK text around `*` / `**` stays raw when it is valid under this specification instead of being escaped as character references.
173
+ This plugin also wires the reverse path for `remark-stringify` / `mdast-util-to-markdown`, so CJK text around `*` / `**` stays raw when it is valid under this specification instead of being escaped as character references. If you don't need this (only need Markdown parsing), or don't need parsing and only need this serialization, you can import from `remark-cjk-friendly/parseOnly` or `remark-cjk-friendly/serializeOnly` instead of `remark-cjk-friendly` to avoid bundling the unnecessary processing.
174
174
 
175
- <span lang="ja">このプラグインは`remark-stringify` / `mdast-util-to-markdown`向けの逆方向シリアライズ拡張も自動で配線するため、この仕様で妥当なケースでは`*` / `**`の前後にあるCJK文字が文字参照へエスケープされず、そのまま出力されます。</span>
175
+ <span lang="ja">このプラグインは`remark-stringify` / `mdast-util-to-markdown`向けの逆方向シリアライズ拡張も自動で配線するため、この仕様で妥当なケースでは`*` / `**`の前後にあるCJK文字が文字参照へエスケープされず、そのまま出力されます。これが不要(Markdownのパースのみが必要)、またはパースが不要でこのシリアライズのみが必要な場合は、`remark-cjk-friendly`の代わりにそれぞれ`remark-cjk-friendly/parseOnly`または`remark-cjk-friendly/serializeOnly`からインポートすると、不要な方の処理のバンドルを避けることができます。</span>
176
176
 
177
- <span lang="zh-Hans-CN">此插件还会自动接入 `remark-stringify` / `mdast-util-to-markdown` 的反向序列化扩展,因此在本规范允许的情况下,`*` / `**` 周围的 CJK 文字会保持原样输出,而不会被转义为字符引用。</span>
177
+ <span lang="zh-Hans-CN">此插件还会自动接入 `remark-stringify` / `mdast-util-to-markdown` 的反向序列化扩展,因此在本规范允许的情况下,`*` / `**` 周围的 CJK 文字会保持原样输出,而不会被转义为字符引用。如果不需要此功能(仅需要 Markdown 解析),或者不需要解析仅需要序列化,可以分别从 `remark-cjk-friendly/parseOnly` 或 `remark-cjk-friendly/serializeOnly` 导入,而不是从 `remark-cjk-friendly` 导入,以避免打包不必要的处理。</span>
178
178
 
179
- <span lang="ko">이 플러그인은 `remark-stringify` / `mdast-util-to-markdown`용 역방향 직렬화 확장도 자동으로 연결하므로, 이 사양에서 유효한 경우 `*` / `**` 주변의 CJK 문자가 문자 참조로 이스케이프되지 않고 그대로 출력됩니다.</span>
179
+ <span lang="ko">이 플러그인은 `remark-stringify` / `mdast-util-to-markdown`용 역방향 직렬화 확장도 자동으로 연결하므로, 이 사양에서 유효한 경우 `*` / `**` 주변의 CJK 문자가 문자 참조로 이스케이프되지 않고 그대로 출력됩니다. 이 기능이 필요 없는 경우(Markdown 파싱만 필요)또는 파싱이 필요 없고 직렬화만 필요한 경우, `remark-cjk-friendly` 대신 각각 `remark-cjk-friendly/parseOnly` 또는 `remark-cjk-friendly/serializeOnly`에서 가져오면 불필요한 처리 번들을 피할 수 있습니다.</span>
180
180
 
181
181
  For MDX, add `remarkCjkFriendly` to the `remarkPlugins` array in the config object:
182
182
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  //#region src/index.d.ts
2
2
  /**
3
3
  * Make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK).
4
+ *
5
+ * This plugin supports both parsing and serializing. If you want to support only one of them, it is recommended to use {@linkcode remarkCjkFriendlyParseOnly} (`remark-cjk-friendly/parseOnly`) or {@linkcode remarkCjkFriendlySerializeOnly} (`remark-cjk-friendly/serializeOnly`) instead to minimize bundled dependencies.
4
6
  */
5
7
  declare function remarkCjkFriendly(this: unknown): void;
6
8
  //#endregion
package/dist/index.js CHANGED
@@ -1,16 +1,15 @@
1
- import { cjkFriendlyToMarkdown } from "mdast-util-to-markdown-cjk-friendly";
2
- import { cjkFriendlyExtension } from "micromark-extension-cjk-friendly";
1
+ import remarkCjkFriendlyParseOnly from "./parseOnly.js";
2
+ import remarkCjkFriendlySerializeOnly from "./serializeOnly.js";
3
3
 
4
4
  //#region src/index.ts
5
5
  /**
6
6
  * Make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK).
7
+ *
8
+ * This plugin supports both parsing and serializing. If you want to support only one of them, it is recommended to use {@linkcode remarkCjkFriendlyParseOnly} (`remark-cjk-friendly/parseOnly`) or {@linkcode remarkCjkFriendlySerializeOnly} (`remark-cjk-friendly/serializeOnly`) instead to minimize bundled dependencies.
7
9
  */
8
10
  function remarkCjkFriendly() {
9
- const data = this.data();
10
- const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
11
- const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
12
- micromarkExtensions.push(cjkFriendlyExtension());
13
- toMarkdownExtensions.push(cjkFriendlyToMarkdown());
11
+ remarkCjkFriendlyParseOnly.call(this);
12
+ remarkCjkFriendlySerializeOnly.call(this);
14
13
  }
15
14
 
16
15
  //#endregion
@@ -0,0 +1,9 @@
1
+ //#region src/parseOnly.d.ts
2
+ /**
3
+ * Make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK).
4
+ *
5
+ * This plugin only supports parsing. If you have been using {@linkcode remarkCjkFriendly} (`remark-cjk-friendly`) since v2.0.1 or earlier, it is recommended to migrate to this to minimize bundled dependencies.
6
+ */
7
+ declare function remarkCjkFriendlyParseOnly(this: unknown): void;
8
+ //#endregion
9
+ export { remarkCjkFriendlyParseOnly as default };
@@ -0,0 +1,15 @@
1
+ import { cjkFriendlyExtension } from "micromark-extension-cjk-friendly";
2
+
3
+ //#region src/parseOnly.ts
4
+ /**
5
+ * Make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK).
6
+ *
7
+ * This plugin only supports parsing. If you have been using {@linkcode remarkCjkFriendly} (`remark-cjk-friendly`) since v2.0.1 or earlier, it is recommended to migrate to this to minimize bundled dependencies.
8
+ */
9
+ function remarkCjkFriendlyParseOnly() {
10
+ const data = this.data();
11
+ (data.micromarkExtensions || (data.micromarkExtensions = [])).push(cjkFriendlyExtension());
12
+ }
13
+
14
+ //#endregion
15
+ export { remarkCjkFriendlyParseOnly as default };
@@ -0,0 +1,9 @@
1
+ //#region src/serializeOnly.d.ts
2
+ /**
3
+ * Make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK).
4
+ *
5
+ * This plugin only supports serializing.
6
+ */
7
+ declare function remarkCjkFriendlySerializeOnly(this: unknown): void;
8
+ //#endregion
9
+ export { remarkCjkFriendlySerializeOnly as default };
@@ -0,0 +1,15 @@
1
+ import { cjkFriendlyToMarkdown } from "mdast-util-to-markdown-cjk-friendly";
2
+
3
+ //#region src/serializeOnly.ts
4
+ /**
5
+ * Make Markdown emphasis (`**`) in CommonMark more friendly with Chinese, Japanese, and Korean (CJK).
6
+ *
7
+ * This plugin only supports serializing.
8
+ */
9
+ function remarkCjkFriendlySerializeOnly() {
10
+ const data = this.data();
11
+ (data.toMarkdownExtensions || (data.toMarkdownExtensions = [])).push(cjkFriendlyToMarkdown());
12
+ }
13
+
14
+ //#endregion
15
+ export { remarkCjkFriendlySerializeOnly as default };
package/package.json CHANGED
@@ -1,12 +1,20 @@
1
1
  {
2
2
  "name": "remark-cjk-friendly",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
8
8
  "default": "./dist/index.js"
9
9
  },
10
+ "./parseOnly": {
11
+ "types": "./dist/parseOnly.d.ts",
12
+ "default": "./dist/parseOnly.js"
13
+ },
14
+ "./serializeOnly": {
15
+ "types": "./dist/serializeOnly.d.ts",
16
+ "default": "./dist/serializeOnly.js"
17
+ },
10
18
  "./package.json": "./package.json"
11
19
  },
12
20
  "module": "./dist/index.js",
@@ -36,8 +44,8 @@
36
44
  "description": "remark plugin to make Markdown emphasis (`**`) in CommonMark (and MDX) more friendly with Chinese, Japanese, and Korean (CJK)",
37
45
  "sideEffects": false,
38
46
  "dependencies": {
39
- "mdast-util-to-markdown-cjk-friendly": "1.0.0",
40
- "micromark-extension-cjk-friendly": "2.0.1"
47
+ "micromark-extension-cjk-friendly": "2.0.1",
48
+ "mdast-util-to-markdown-cjk-friendly": "1.0.0"
41
49
  },
42
50
  "devDependencies": {
43
51
  "@mdx-js/mdx": "^3.1.1",