@alauda/doom 1.4.1 → 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/lint.js +2 -56
- package/lib/cli/load-config.d.ts +2 -2
- package/lib/cli/load-config.js +14 -8
- package/lib/cli/translate.js +1 -1
- package/lib/cspell.d.ts +2 -0
- package/lib/cspell.js +67 -0
- package/lib/eslint.d.ts +5 -0
- package/lib/eslint.js +76 -0
- 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 +4 -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/lint.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import cspellRecommended from '@cspell/eslint-plugin/recommended';
|
|
2
|
-
import js from '@eslint/js';
|
|
3
|
-
import react from '@eslint-react/eslint-plugin';
|
|
4
1
|
import { logger } from '@rspress/shared/logger';
|
|
5
2
|
import { Command } from 'commander';
|
|
6
|
-
import { merge } from 'es-toolkit/compat';
|
|
7
3
|
import { ESLint } from 'eslint';
|
|
8
|
-
import
|
|
9
|
-
import tseslint from 'typescript-eslint';
|
|
10
|
-
import { parseTerms } from './helpers.js';
|
|
4
|
+
import doom from '../eslint.js';
|
|
11
5
|
import { loadConfig } from './load-config.js';
|
|
12
6
|
export const lintCommand = new Command('lint')
|
|
13
7
|
.description('Lint the documentation')
|
|
@@ -16,59 +10,11 @@ export const lintCommand = new Command('lint')
|
|
|
16
10
|
const globalOptions = this.optsWithGlobals();
|
|
17
11
|
const { config } = await loadConfig(root, globalOptions);
|
|
18
12
|
const docsDir = config.root;
|
|
19
|
-
const parsedTerms = await parseTerms();
|
|
20
13
|
const eslint = new ESLint({
|
|
21
14
|
cwd: docsDir,
|
|
22
15
|
overrideConfigFile: true,
|
|
23
16
|
// @ts-expect-error -- stronger types
|
|
24
|
-
overrideConfig:
|
|
25
|
-
{
|
|
26
|
-
extends: [
|
|
27
|
-
js.configs.recommended,
|
|
28
|
-
react.configs.recommended,
|
|
29
|
-
mdx.configs.flat,
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
files: ['**/en/**/*.{js,jsx,md,mdx,ts,tsx}'],
|
|
34
|
-
extends: [cspellRecommended],
|
|
35
|
-
rules: {
|
|
36
|
-
'@cspell/spellchecker': [
|
|
37
|
-
'error',
|
|
38
|
-
merge({
|
|
39
|
-
autoFix: true,
|
|
40
|
-
cspell: {
|
|
41
|
-
allowCompoundWords: true,
|
|
42
|
-
words: parsedTerms.map((it) => it.en),
|
|
43
|
-
flagWords: parsedTerms.flatMap(({ badCases }) => badCases?.en ?? []),
|
|
44
|
-
},
|
|
45
|
-
}, config.lint?.cspellOptions),
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
files: ['**/*.{ts,tsx}'],
|
|
51
|
-
extends: [
|
|
52
|
-
tseslint.configs.recommendedTypeChecked,
|
|
53
|
-
react.configs['recommended-typescript'],
|
|
54
|
-
],
|
|
55
|
-
rules: {
|
|
56
|
-
'@typescript-eslint/no-misused-promises': 'off',
|
|
57
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
58
|
-
'@typescript-eslint/restrict-template-expressions': [
|
|
59
|
-
'error',
|
|
60
|
-
{ allowNumber: true },
|
|
61
|
-
],
|
|
62
|
-
'prefer-const': ['error', { destructuring: 'all' }],
|
|
63
|
-
},
|
|
64
|
-
languageOptions: {
|
|
65
|
-
parser: tseslint.parser,
|
|
66
|
-
parserOptions: {
|
|
67
|
-
projectService: true,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
]),
|
|
17
|
+
overrideConfig: await doom(config.lint?.cspellOptions),
|
|
72
18
|
});
|
|
73
19
|
logger.start('Linting...');
|
|
74
20
|
const results = await eslint.lintFiles('**/*.{js,jsx,ts,tsx,md,mdx}');
|
package/lib/cli/load-config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type UserConfig } from '@rspress/core';
|
|
2
2
|
import type { GlobalCliOptions } from '../types.js';
|
|
3
|
-
export declare function loadConfig(root?: string, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, algolia, siteUrl, }?: GlobalCliOptions): Promise<{
|
|
3
|
+
export declare function loadConfig(root?: string | URL, { config: configFile, base, prefix, v: version, download, export: export_, ignore, force, open, lazy, include, exclude, outDir, redirect, editRepo, algolia, siteUrl, }?: GlobalCliOptions): Promise<{
|
|
4
4
|
config: UserConfig;
|
|
5
5
|
filepath?: string;
|
|
6
6
|
}>;
|
|
7
|
-
export declare function resolveDocRoot(
|
|
7
|
+
export declare function resolveDocRoot(cliRoot?: string, configRoot?: string): string;
|
package/lib/cli/load-config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { pluginReact } from '@rsbuild/plugin-react';
|
|
4
5
|
import { pluginSass } from '@rsbuild/plugin-sass';
|
|
5
6
|
import { pluginSvgr } from '@rsbuild/plugin-svgr';
|
|
@@ -14,7 +15,7 @@ import { cyan } from 'yoctocolors';
|
|
|
14
15
|
import { apiPlugin, autoSidebarPlugin, autoTocPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, sitemapPlugin, } from '../plugins/index.js';
|
|
15
16
|
import { isExplicitlyUnversioned, UNVERSIONED, } from '../shared/index.js';
|
|
16
17
|
import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
|
|
17
|
-
import {
|
|
18
|
+
import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
|
|
18
19
|
import { defaultGitHubUrl } from './helpers.js';
|
|
19
20
|
const DEFAULT_LOGO = '/logo.svg';
|
|
20
21
|
const KNOWN_LOCALE_CONFIGS = {
|
|
@@ -61,7 +62,7 @@ const ALAUDA_RU_ALGOLIA_OPTIONS = {
|
|
|
61
62
|
};
|
|
62
63
|
const getCommonConfig = async ({ config, root, configFilePath, base, version, download, export: export_, ignore, force, open, lazy, include, exclude, redirect, editRepo, algolia, siteUrl, }) => {
|
|
63
64
|
const fallbackToZh = 'lang' in config && !config.lang;
|
|
64
|
-
root = resolveDocRoot(
|
|
65
|
+
root = resolveDocRoot(root, config.root);
|
|
65
66
|
const localBasePath = configFilePath ? path.dirname(configFilePath) : root;
|
|
66
67
|
const userBase = (base = addLeadingSlash(addTrailingSlash(base || config.base || '/')));
|
|
67
68
|
if (version && !isExplicitlyUnversioned(version)) {
|
|
@@ -86,7 +87,8 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
|
|
|
86
87
|
const dirents = await fs.readdir(root, { withFileTypes: true });
|
|
87
88
|
for (const dirent of dirents) {
|
|
88
89
|
const { name } = dirent;
|
|
89
|
-
if (!dirent.isDirectory() ||
|
|
90
|
+
if (!dirent.isDirectory() ||
|
|
91
|
+
['dist', 'node_modules', 'public', 'shared'].includes(name)) {
|
|
90
92
|
continue;
|
|
91
93
|
}
|
|
92
94
|
allLanguages.push(name);
|
|
@@ -246,6 +248,10 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
246
248
|
}
|
|
247
249
|
else {
|
|
248
250
|
if (root) {
|
|
251
|
+
root = root.toString();
|
|
252
|
+
if (root.startsWith('file:')) {
|
|
253
|
+
root = fileURLToPath(root);
|
|
254
|
+
}
|
|
249
255
|
configFilePath = await findConfig(path.resolve(root, DEFAULT_CONFIG_NAME));
|
|
250
256
|
}
|
|
251
257
|
if (!configFilePath) {
|
|
@@ -292,7 +298,7 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
292
298
|
const commonConfig = await getCommonConfig({
|
|
293
299
|
config,
|
|
294
300
|
configFilePath,
|
|
295
|
-
root,
|
|
301
|
+
root: root,
|
|
296
302
|
base,
|
|
297
303
|
version,
|
|
298
304
|
download,
|
|
@@ -353,15 +359,15 @@ export async function loadConfig(root, { config: configFile, base, prefix, v: ve
|
|
|
353
359
|
filepath: configFilePath,
|
|
354
360
|
};
|
|
355
361
|
}
|
|
356
|
-
export function resolveDocRoot(
|
|
362
|
+
export function resolveDocRoot(cliRoot, configRoot) {
|
|
357
363
|
// CLI root has highest priority
|
|
358
364
|
if (cliRoot) {
|
|
359
|
-
return path.
|
|
365
|
+
return path.resolve(cliRoot);
|
|
360
366
|
}
|
|
361
367
|
// Config root is next in priority
|
|
362
368
|
if (configRoot) {
|
|
363
|
-
return path.isAbsolute(configRoot) ? configRoot : path.
|
|
369
|
+
return path.isAbsolute(configRoot) ? configRoot : path.resolve(configRoot);
|
|
364
370
|
}
|
|
365
371
|
// Default to 'docs' if no root is specified
|
|
366
|
-
return path.
|
|
372
|
+
return path.resolve('docs');
|
|
367
373
|
}
|
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
|
package/lib/cspell.d.ts
ADDED
package/lib/cspell.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { parseTerms } from './cli/helpers.js';
|
|
4
|
+
const resolveDictionaries = async () => {
|
|
5
|
+
const dictionariesDir = path.resolve('.cspell');
|
|
6
|
+
try {
|
|
7
|
+
if (!(await fs.stat(dictionariesDir)).isDirectory()) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const dictionaries = [];
|
|
15
|
+
const dictionaryDefinitions = [];
|
|
16
|
+
for (const file of await fs.readdir(dictionariesDir, {
|
|
17
|
+
withFileTypes: true,
|
|
18
|
+
})) {
|
|
19
|
+
if (!file.isFile()) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const dictionary = path.parse(file.name).name;
|
|
23
|
+
dictionaries.push(dictionary);
|
|
24
|
+
dictionaryDefinitions.push({
|
|
25
|
+
name: dictionary,
|
|
26
|
+
path: `.cspell/${file.name}`,
|
|
27
|
+
addWords: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return { dictionaries, dictionaryDefinitions };
|
|
31
|
+
};
|
|
32
|
+
const CASE_SENSITIVE_DICTIONARY = '$$case-sensitive$$';
|
|
33
|
+
export default async function doom() {
|
|
34
|
+
const parsedTerms = await parseTerms();
|
|
35
|
+
const words = [];
|
|
36
|
+
const caseSensitiveWords = [];
|
|
37
|
+
const flagWords = parsedTerms.flatMap((it) => {
|
|
38
|
+
const word = it.en;
|
|
39
|
+
const badCases = it.badCases?.en ?? [];
|
|
40
|
+
if (badCases.some((c) => word !== c && word.toLowerCase() === c.toLowerCase())) {
|
|
41
|
+
caseSensitiveWords.push(it);
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
words.push(word);
|
|
45
|
+
return badCases.map((c) => `${c}->${word}`);
|
|
46
|
+
});
|
|
47
|
+
const { dictionaries = [], dictionaryDefinitions = [] } = (await resolveDictionaries()) ?? {};
|
|
48
|
+
if (caseSensitiveWords.length) {
|
|
49
|
+
dictionaries.push(CASE_SENSITIVE_DICTIONARY);
|
|
50
|
+
dictionaryDefinitions.push({
|
|
51
|
+
name: CASE_SENSITIVE_DICTIONARY,
|
|
52
|
+
words: caseSensitiveWords.flatMap((it) => [
|
|
53
|
+
it.en,
|
|
54
|
+
...(it.badCases?.en ?? []).map((c) => `!${c}`),
|
|
55
|
+
]),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
allowCompoundWords: true,
|
|
60
|
+
language: 'en,en-GB,en-US',
|
|
61
|
+
useGitignore: true,
|
|
62
|
+
words,
|
|
63
|
+
flagWords,
|
|
64
|
+
dictionaries,
|
|
65
|
+
dictionaryDefinitions,
|
|
66
|
+
};
|
|
67
|
+
}
|
package/lib/eslint.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Options } from '@cspell/eslint-plugin';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
declare function doom(cspellOptions?: Options): Promise<tseslint.ConfigArray>;
|
|
4
|
+
declare function doom(root: string | URL): Promise<tseslint.ConfigArray>;
|
|
5
|
+
export default doom;
|
package/lib/eslint.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import cspellRecommended from '@cspell/eslint-plugin/recommended';
|
|
2
|
+
import js from '@eslint/js';
|
|
3
|
+
import react from '@eslint-react/eslint-plugin';
|
|
4
|
+
import { merge } from 'es-toolkit/compat';
|
|
5
|
+
import * as mdx from 'eslint-plugin-mdx';
|
|
6
|
+
import globals from 'globals';
|
|
7
|
+
import tseslint from 'typescript-eslint';
|
|
8
|
+
import { loadConfig } from './cli/load-config.js';
|
|
9
|
+
async function doom(cspellOptionsOrRoot) {
|
|
10
|
+
let cspellOptions;
|
|
11
|
+
if (typeof cspellOptionsOrRoot === 'string' ||
|
|
12
|
+
cspellOptionsOrRoot instanceof URL) {
|
|
13
|
+
const { config } = await loadConfig(cspellOptionsOrRoot);
|
|
14
|
+
cspellOptions = config.lint?.cspellOptions;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
cspellOptions = cspellOptionsOrRoot;
|
|
18
|
+
}
|
|
19
|
+
return tseslint.config([
|
|
20
|
+
{
|
|
21
|
+
ignores: ['**/.yarn', '**/dist', '**/lib', '**/node_modules'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
extends: [
|
|
25
|
+
js.configs.recommended,
|
|
26
|
+
react.configs.recommended,
|
|
27
|
+
mdx.configs.flat,
|
|
28
|
+
],
|
|
29
|
+
languageOptions: {
|
|
30
|
+
globals: globals.node,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
files: ['**/en/**/*.{js,jsx,md,mdx,ts,tsx}'],
|
|
35
|
+
extends: [cspellRecommended],
|
|
36
|
+
languageOptions: {
|
|
37
|
+
globals: globals.browser,
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
'@cspell/spellchecker': [
|
|
41
|
+
'error',
|
|
42
|
+
merge({ autoFix: true }, cspellOptions),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
files: ['**/*.mdx'],
|
|
48
|
+
rules: {
|
|
49
|
+
'no-unused-expressions': 'off',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
files: ['**/*.{ts,tsx}'],
|
|
54
|
+
extends: [
|
|
55
|
+
tseslint.configs.recommendedTypeChecked,
|
|
56
|
+
react.configs['recommended-typescript'],
|
|
57
|
+
],
|
|
58
|
+
rules: {
|
|
59
|
+
'@typescript-eslint/no-misused-promises': 'off',
|
|
60
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
61
|
+
'@typescript-eslint/restrict-template-expressions': [
|
|
62
|
+
'error',
|
|
63
|
+
{ allowNumber: true },
|
|
64
|
+
],
|
|
65
|
+
'prefer-const': ['error', { destructuring: 'all' }],
|
|
66
|
+
},
|
|
67
|
+
languageOptions: {
|
|
68
|
+
parser: tseslint.parser,
|
|
69
|
+
parserOptions: {
|
|
70
|
+
projectService: true,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
export default doom;
|
|
@@ -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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": "git+https://github.com/alauda/doom.git",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
"./package.json": "./package.json",
|
|
15
15
|
"./config": "./lib/config.js",
|
|
16
|
+
"./cspell": "./lib/cspell.js",
|
|
17
|
+
"./eslint": "./lib/eslint.js",
|
|
16
18
|
"./runtime": "./lib/runtime/index.js",
|
|
17
19
|
"./theme": "./lib/theme.js",
|
|
18
20
|
"./types": "./lib/types.js"
|
|
@@ -56,6 +58,7 @@
|
|
|
56
58
|
"es-toolkit": "^1.39.3",
|
|
57
59
|
"eslint": "^9.29.0",
|
|
58
60
|
"eslint-plugin-mdx": "^3.5.0",
|
|
61
|
+
"globals": "^16.2.0",
|
|
59
62
|
"html-tag-names": "^2.1.0",
|
|
60
63
|
"mdast-util-mdx": "^3.0.0",
|
|
61
64
|
"mdast-util-mdx-jsx": "^3.2.0",
|