@alauda/doom 1.5.0 → 1.5.1
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/lib/cli/helpers.js +1 -1
- package/lib/cli/html-export-pdf/core/outline.js +1 -1
- package/lib/cli/load-config.js +2 -1
- package/lib/cli/translate.js +1 -1
- package/lib/plugins/auto-sidebar/utils.js +2 -1
- package/lib/plugins/replace/remark-replace.js +3 -2
- package/lib/plugins/replace/utils.js +5 -2
- package/package.json +1 -1
package/lib/cli/helpers.js
CHANGED
|
@@ -35,7 +35,7 @@ export function escapeMarkdownHeadingIds(content) {
|
|
|
35
35
|
}
|
|
36
36
|
export const defaultGitHubUrl = (url) => /^https?:\/\//.test(url)
|
|
37
37
|
? url
|
|
38
|
-
: `https://github.com/${url.replace(/^(
|
|
38
|
+
: `https://github.com/${url.replace(/^(?:\/*github.com)?\/+/i, '')}`;
|
|
39
39
|
const parseTerms_ = async () => {
|
|
40
40
|
const terms = await xfetch(process.env.RAW_TERMS_URL ||
|
|
41
41
|
'https://gitlab-ce.alauda.cn/alauda-public/product-doc-guide/-/raw/main/terms.yaml', { type: 'text' });
|
|
@@ -62,7 +62,7 @@ export async function getOutlineNodes(page, tags, outlineContainerSelector = '')
|
|
|
62
62
|
else {
|
|
63
63
|
const newNode = {
|
|
64
64
|
// http://perfectionkills.com/the-poor-misunderstood-innerText/
|
|
65
|
-
title: tag.textContent?.trim().replace(
|
|
65
|
+
title: tag.textContent?.trim().replace(/^#|#$/, '') ?? '',
|
|
66
66
|
destination: dest,
|
|
67
67
|
children: [],
|
|
68
68
|
depth: orderDepth,
|
package/lib/cli/load-config.js
CHANGED
|
@@ -87,7 +87,8 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
87
87
|
const dirents = await fs.readdir(root, { withFileTypes: true });
|
|
88
88
|
for (const dirent of dirents) {
|
|
89
89
|
const { name } = dirent;
|
|
90
|
-
if (!dirent.isDirectory() ||
|
|
90
|
+
if (!dirent.isDirectory() ||
|
|
91
|
+
['dist', 'node_modules', 'public', 'shared'].includes(name)) {
|
|
91
92
|
continue;
|
|
92
93
|
}
|
|
93
94
|
allLanguages.push(name);
|
package/lib/cli/translate.js
CHANGED
|
@@ -110,7 +110,7 @@ const resolveTerms = async (sourceLang, targetLang, sourceContent) => {
|
|
|
110
110
|
logger.debug('Resolved terms:', terms);
|
|
111
111
|
return terms;
|
|
112
112
|
};
|
|
113
|
-
const ANCHOR_REGEX =
|
|
113
|
+
const ANCHOR_REGEX = /\\\\?\{#[\w-]+\}/g;
|
|
114
114
|
function replaceAnchorsWithPlaceholders(content) {
|
|
115
115
|
// Handle escaped underscores in anchor IDs (e.g., \{#independent\_doc\_site} -> \{#independent_doc_site})
|
|
116
116
|
// This is necessary because MDX processor automatically escapes underscores in heading IDs
|
|
@@ -33,12 +33,13 @@ export async function extractInfoFromFrontmatter(filePath, rootDir, extensions)
|
|
|
33
33
|
}
|
|
34
34
|
const content = await fs.readFile(realPath, 'utf-8');
|
|
35
35
|
const fileNameWithoutExt = path.basename(realPath, path.extname(realPath));
|
|
36
|
+
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
36
37
|
const h1RegExp = /^#\s+(.*)$/m;
|
|
37
38
|
const match = content.match(h1RegExp);
|
|
38
39
|
let contentTitle = match?.[1]?.trim();
|
|
39
40
|
if (contentTitle) {
|
|
40
41
|
contentTitle =
|
|
41
|
-
contentTitle.match(
|
|
42
|
+
contentTitle.match(/\{\s*useI18n\s*\(\s*\)\s*\(\s*(['"])([^'"]+)\1\s*\)\s*\}/)?.[2] ?? contentTitle;
|
|
42
43
|
}
|
|
43
44
|
const { frontmatter } = loadFrontMatter(content, filePath, rootDir);
|
|
44
45
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable regexp/optimal-quantifier-concatenation, regexp/no-misleading-capturing-group, regexp/no-super-linear-backtracking */
|
|
1
2
|
import fs from 'node:fs/promises';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { isProduction } from '@rspress/core';
|
|
@@ -9,12 +10,12 @@ import { resolveReference } from './resolve-reference.js';
|
|
|
9
10
|
import { resolveRelease } from './resolve-release.js';
|
|
10
11
|
import { getFrontmatterNode, isCI, mdProcessor, mdxProcessor } from './utils.js';
|
|
11
12
|
const MD_REF_START_COMMENT_PATTERN = /<!-{2,} *reference-start#(.+) *-{2,}>/;
|
|
12
|
-
const MDX_REF_START_COMMENT_PATTERN =
|
|
13
|
+
const MDX_REF_START_COMMENT_PATTERN = /\{\/\*+ *reference-start#(.+) *\*+\/\}/;
|
|
13
14
|
const MDX_REF_START_PATTERN = /\/\*+ *reference-start#(.+) *\*+\//;
|
|
14
15
|
const MD_REF_END_COMMENT_PATTERN = /<!-{2,} *reference-end *-{2,}>/;
|
|
15
16
|
const MDX_REF_END_PATTERN = /\/\*+ *reference-end *\*+\//;
|
|
16
17
|
export const MD_RELEASE_COMMENT_PATTERN = /<!-{2,} *release-notes-for-bugs\?(.+) *-{2,}>/;
|
|
17
|
-
export const MDX_RELEASE_COMMENT_PATTERN =
|
|
18
|
+
export const MDX_RELEASE_COMMENT_PATTERN = /\{\/\*+ *release-notes-for-bugs\?(.+) *\*+\/\}/;
|
|
18
19
|
const MDX_RELEASE_PATTERN = /\/\*+ *release-notes-for-bugs\?(.+) *\*+\//;
|
|
19
20
|
export const maybeHaveRef = (filepath, content) => {
|
|
20
21
|
if (!/\.mdx?$/.test(filepath)) {
|
|
@@ -11,10 +11,13 @@ export const RELATIVE_URL_PATTERN = /^\.\.?\//;
|
|
|
11
11
|
* hello world {#custom-id} -> { text: 'hello world', id: 'custom-id' }
|
|
12
12
|
*/
|
|
13
13
|
export const extractTextAndId = (title) => {
|
|
14
|
-
const customIdReg =
|
|
14
|
+
const customIdReg = /\\?\{#[^}]*\}/;
|
|
15
15
|
const text = title.replace(customIdReg, '').trimEnd();
|
|
16
16
|
const customId = title.match(customIdReg)?.[0]?.slice(2, -1) || '';
|
|
17
|
-
return [
|
|
17
|
+
return [
|
|
18
|
+
text.replace(/\\{2}/g, '').replace(/(?:[^\\]\\([[\]]))+/g, '$1'),
|
|
19
|
+
customId,
|
|
20
|
+
];
|
|
18
21
|
};
|
|
19
22
|
export const normalizeReferenceItems = (items = []) => items.reduce((acc, curr) => {
|
|
20
23
|
for (const source of curr.sources) {
|