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-
|
|
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 =
|
|
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-
|
|
1
|
+
import { n as cjkFriendlyPhrasingHandlers, t as cjkFriendlyAttention } from "./phrasing-D74LUlZv.mjs";
|
|
2
2
|
export { cjkFriendlyAttention, cjkFriendlyPhrasingHandlers };
|