gtx-cli 2.1.18 → 2.1.19
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# gtx-cli
|
|
2
2
|
|
|
3
|
+
## 2.1.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#641](https://github.com/generaltranslation/gt/pull/641) [`4c67f77`](https://github.com/generaltranslation/gt/commit/4c67f775ee892b47eebcc3178c00ad6547a84d84) Thanks [@fernando-aviles](https://github.com/fernando-aviles)! - Encoding placeholders that break MDX parse
|
|
8
|
+
|
|
3
9
|
## 2.1.18
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ import remarkFrontmatter from 'remark-frontmatter';
|
|
|
5
5
|
import remarkStringify from 'remark-stringify';
|
|
6
6
|
import { visit } from 'unist-util-visit';
|
|
7
7
|
import { logWarning } from '../console/logging.js';
|
|
8
|
+
import { encodeAnglePlaceholders } from './encodePlaceholders.js';
|
|
8
9
|
/**
|
|
9
10
|
* Generates a slug from heading text
|
|
10
11
|
*/
|
|
@@ -173,6 +174,9 @@ function applyInlineIds(translatedContent, idMappings) {
|
|
|
173
174
|
// Convert the modified AST back to MDX string
|
|
174
175
|
try {
|
|
175
176
|
const stringifyProcessor = unified()
|
|
177
|
+
.use(remarkFrontmatter, ['yaml', 'toml'])
|
|
178
|
+
.use(remarkMdx)
|
|
179
|
+
.use(encodeAnglePlaceholders)
|
|
176
180
|
.use(remarkStringify, {
|
|
177
181
|
bullet: '-',
|
|
178
182
|
emphasis: '_',
|
|
@@ -186,10 +190,9 @@ function applyInlineIds(translatedContent, idMappings) {
|
|
|
186
190
|
return node.value;
|
|
187
191
|
},
|
|
188
192
|
},
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
let content = stringifyProcessor.stringify(processedAst);
|
|
193
|
+
});
|
|
194
|
+
const outTree = stringifyProcessor.runSync(processedAst);
|
|
195
|
+
let content = stringifyProcessor.stringify(outTree);
|
|
193
196
|
// Handle newline formatting to match original input
|
|
194
197
|
if (content.endsWith('\n') && !translatedContent.endsWith('\n')) {
|
|
195
198
|
content = content.slice(0, -1);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin } from 'unified';
|
|
2
|
+
import type { Root } from 'mdast';
|
|
3
|
+
/**
|
|
4
|
+
* Re-encode angle-bracket placeholders like <accountName> -> <accountName>
|
|
5
|
+
* in plain text, to prevent MDX JSX parsing on re-parse.
|
|
6
|
+
*
|
|
7
|
+
* - Only touches Text nodes.
|
|
8
|
+
* - Idempotent: already-encoded entities are left unchanged.
|
|
9
|
+
* - Does NOT affect actual MDX/JSX elements because those are not text nodes.
|
|
10
|
+
*/
|
|
11
|
+
export declare const encodeAnglePlaceholders: Plugin<[], Root>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { findAndReplace } from 'mdast-util-find-and-replace';
|
|
2
|
+
const IGNORE_PARENTS = [
|
|
3
|
+
'code',
|
|
4
|
+
'inlineCode',
|
|
5
|
+
'mdxFlowExpression',
|
|
6
|
+
'mdxTextExpression',
|
|
7
|
+
'mdxjsEsm',
|
|
8
|
+
'yaml',
|
|
9
|
+
'toml',
|
|
10
|
+
'math',
|
|
11
|
+
'inlineMath',
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Re-encode angle-bracket placeholders like <accountName> -> <accountName>
|
|
15
|
+
* in plain text, to prevent MDX JSX parsing on re-parse.
|
|
16
|
+
*
|
|
17
|
+
* - Only touches Text nodes.
|
|
18
|
+
* - Idempotent: already-encoded entities are left unchanged.
|
|
19
|
+
* - Does NOT affect actual MDX/JSX elements because those are not text nodes.
|
|
20
|
+
*/
|
|
21
|
+
export const encodeAnglePlaceholders = function () {
|
|
22
|
+
return (tree) => {
|
|
23
|
+
findAndReplace(tree, [
|
|
24
|
+
[
|
|
25
|
+
/<([A-Za-z][\w.-]*)>/g, // <content>, <con-tent>, <con.tent>, <con_tent>
|
|
26
|
+
(_match, name) => `<${name}>`,
|
|
27
|
+
],
|
|
28
|
+
], { ignore: IGNORE_PARENTS });
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -7,6 +7,7 @@ import remarkMdx from 'remark-mdx';
|
|
|
7
7
|
import remarkFrontmatter from 'remark-frontmatter';
|
|
8
8
|
import remarkStringify from 'remark-stringify';
|
|
9
9
|
import { visit } from 'unist-util-visit';
|
|
10
|
+
import { encodeAnglePlaceholders } from './encodePlaceholders.js';
|
|
10
11
|
const { isMatch } = micromatch;
|
|
11
12
|
/**
|
|
12
13
|
* Localizes static urls in content files.
|
|
@@ -370,6 +371,9 @@ function transformMdxUrls(mdxContent, defaultLocale, targetLocale, hideDefaultLo
|
|
|
370
371
|
let content;
|
|
371
372
|
try {
|
|
372
373
|
const stringifyProcessor = unified()
|
|
374
|
+
.use(remarkFrontmatter, ['yaml', 'toml'])
|
|
375
|
+
.use(remarkMdx)
|
|
376
|
+
.use(encodeAnglePlaceholders)
|
|
373
377
|
.use(remarkStringify, {
|
|
374
378
|
bullet: '-',
|
|
375
379
|
emphasis: '_',
|
|
@@ -377,10 +381,15 @@ function transformMdxUrls(mdxContent, defaultLocale, targetLocale, hideDefaultLo
|
|
|
377
381
|
rule: '-',
|
|
378
382
|
ruleRepetition: 3,
|
|
379
383
|
ruleSpaces: false,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
+
handlers: {
|
|
385
|
+
// Handler to prevent escaping (avoids '<' -> '\<')
|
|
386
|
+
text(node) {
|
|
387
|
+
return node.value;
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
const outTree = stringifyProcessor.runSync(processedAst);
|
|
392
|
+
content = stringifyProcessor.stringify(outTree);
|
|
384
393
|
}
|
|
385
394
|
catch (error) {
|
|
386
395
|
console.warn(`Failed to stringify MDX content: ${error instanceof Error ? error.message : String(error)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtx-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.19",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"bin": "dist/main.js",
|
|
6
6
|
"files": [
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"json-pointer": "^0.6.2",
|
|
92
92
|
"jsonpath-plus": "^10.3.0",
|
|
93
93
|
"jsonpointer": "^5.0.1",
|
|
94
|
+
"mdast-util-find-and-replace": "^3.0.2",
|
|
94
95
|
"micromatch": "^4.0.8",
|
|
95
96
|
"open": "^10.1.1",
|
|
96
97
|
"ora": "^8.2.0",
|