mdast-util-to-markdown-cjk-friendly 1.0.1 → 1.0.2

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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as cjkFriendlyPhrasingHandlers, t as cjkFriendlyAttention } from "./phrasing-CVe5_g2v.mjs";
1
+ import { n as cjkFriendlyPhrasingHandlers, t as cjkFriendlyAttention } from "./phrasing-D74LUlZv.mjs";
2
2
  import { defaultHandlers } from "mdast-util-to-markdown";
3
3
  //#region src/index.ts
4
4
  /** Add CJK-friendly `toMarkdown` handlers for emphasis and strong. */
@@ -244,7 +244,14 @@ function encode(tokens, start) {
244
244
  if (!token || token.attention || !token.value) return;
245
245
  const character = start ? firstCharacter(token.value) : lastCharacter(token.value);
246
246
  const reference = `&#x${character.codePointAt(0)?.toString(16).toUpperCase()};`;
247
- token.value = start ? reference + token.value.slice(character.length) : token.value.slice(0, -character.length) + reference;
247
+ if (start) token.value = reference + token.value.slice(character.length);
248
+ else {
249
+ let value = token.value.slice(0, -character.length);
250
+ let escapes = 0;
251
+ while (value.charCodeAt(value.length - 1 - escapes) === 92) escapes++;
252
+ if (escapes % 2) value += "\\";
253
+ token.value = value + reference;
254
+ }
248
255
  }
249
256
  function attentionSequences(type, markers, sizes) {
250
257
  if (!markers.length || !sizes.length) throw new Error(`Cannot serialize ${type} as attention without markers and sizes`);
package/dist/phrasing.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as cjkFriendlyPhrasingHandlers, t as cjkFriendlyAttention } from "./phrasing-CVe5_g2v.mjs";
1
+ import { n as cjkFriendlyPhrasingHandlers, t as cjkFriendlyAttention } from "./phrasing-D74LUlZv.mjs";
2
2
  export { cjkFriendlyAttention, cjkFriendlyPhrasingHandlers };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdast-util-to-markdown-cjk-friendly",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {