@alauda/doom 1.0.0-next.1 → 1.0.0-next.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.
@@ -10,7 +10,7 @@ import { difference } from 'es-toolkit';
10
10
  import rehypeRaw from 'rehype-raw';
11
11
  import { cyan } from 'yoctocolors';
12
12
  import { autoTocPlugin } from '../plugins/auto-toc/index.js';
13
- import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, replacePlugin, } from '../plugins/index.js';
13
+ import { apiPlugin, autoSidebarPlugin, createTransformerCallouts, directivesPlugin, globalPlugin, mermaidPlugin, permissionPlugin, rehypeFix, replacePlugin, } from '../plugins/index.js';
14
14
  import { isExplicitlyUnversioned, UNVERSIONED, } from '../shared/index.js';
15
15
  import { pathExists, pkgResolve, resolveStaticConfig } from '../utils/index.js';
16
16
  import { CWD, DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS, I18N_FILE, SITES_FILE, YAML_EXTENSIONS, } from './constants.js';
@@ -126,7 +126,7 @@ const getCommonConfig = async ({ config, root, configFilePath, base, version, do
126
126
  },
127
127
  markdown: {
128
128
  checkDeadLinks: true,
129
- rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }]],
129
+ rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }], rehypeFix],
130
130
  shiki: {
131
131
  transformers: [
132
132
  // builtin transformers
@@ -1 +1,2 @@
1
1
  export * from './transformers/index.js';
2
+ export * from './rehype-fix.js';
@@ -1 +1,2 @@
1
1
  export * from './transformers/index.js';
2
+ export * from './rehype-fix.js';
@@ -0,0 +1,9 @@
1
+ import type { Root } from 'hast';
2
+ import type { Plugin } from 'unified';
3
+ /**
4
+ * Restores metadata (e.g., titles) for code blocks that `rehype-raw` removes unexpectedly.
5
+ * This function addresses a compatibility issue where `rehype-raw` strips metadata from code blocks.
6
+ * @see https://github.com/syntax-tree/hast-util-raw/issues/29
7
+ * @see https://github.com/web-infra-dev/rspress/blob/ab7567460e63712300b64d7ab46065a2f1c1e069/packages/core/src/node/mdx/rehypePlugins/codeMeta.ts#L5-L22
8
+ */
9
+ export declare const rehypeFix: Plugin<[], Root>;
@@ -0,0 +1,25 @@
1
+ import { visit } from 'unist-util-visit';
2
+ /**
3
+ * Restores metadata (e.g., titles) for code blocks that `rehype-raw` removes unexpectedly.
4
+ * This function addresses a compatibility issue where `rehype-raw` strips metadata from code blocks.
5
+ * @see https://github.com/syntax-tree/hast-util-raw/issues/29
6
+ * @see https://github.com/web-infra-dev/rspress/blob/ab7567460e63712300b64d7ab46065a2f1c1e069/packages/core/src/node/mdx/rehypePlugins/codeMeta.ts#L5-L22
7
+ */
8
+ export const rehypeFix = function () {
9
+ return (ast) => {
10
+ visit(ast, 'element', (node) => {
11
+ // <pre><code>...</code></pre>
12
+ // 1. Find pre element
13
+ const childNode = node.children.at(0);
14
+ if (node.tagName === 'pre' &&
15
+ childNode?.type === 'element' &&
16
+ childNode.tagName === 'code') {
17
+ if (!childNode.data?.meta &&
18
+ typeof childNode.properties.meta === 'string') {
19
+ ;
20
+ (childNode.data ??= {}).meta ??= childNode.properties.meta;
21
+ }
22
+ }
23
+ });
24
+ };
25
+ };
@@ -1,2 +1 @@
1
1
  export * from './callouts.js';
2
- export * from './line-number.js';
@@ -1,2 +1 @@
1
1
  export * from './callouts.js';
2
- export * from './line-number.js';
@@ -18,6 +18,6 @@ export declare const X: {
18
18
  strong: (props: import("react").ComponentProps<"strong">) => import("react/jsx-runtime").JSX.Element;
19
19
  a: (props: import("react").ComponentProps<"a">) => import("react/jsx-runtime").JSX.Element;
20
20
  code: (props: import("react").HTMLProps<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
21
- pre: ({ children, className, title, ...otherProps }: import("@rspress/theme-default").PreWithCodeButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
21
+ pre: ({ containerElementClassName, children, className, title, codeButtonGroupProps, ...otherProps }: import("@rspress/theme-default").PreWithCodeButtonGroupProps) => import("react/jsx-runtime").JSX.Element | null;
22
22
  img: (props: import("react").ComponentProps<"img">) => import("react/jsx-runtime").JSX.Element;
23
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "1.0.0-next.1",
3
+ "version": "1.0.0-next.2",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "git+https://github.com/alauda/doom.git",
@@ -40,7 +40,7 @@
40
40
  "@playwright/browser-chromium": "^1.52.0",
41
41
  "@rsbuild/plugin-sass": "^1.3.1",
42
42
  "@rsbuild/plugin-yaml": "^1.0.2",
43
- "@rspress/core": "2.0.0-beta.7",
43
+ "@rspress/core": "2.0.0-beta.8",
44
44
  "@shikijs/transformers": "^3.4.2",
45
45
  "chokidar": "^4.0.3",
46
46
  "cli-progress": "^3.12.0",
@@ -1,7 +0,0 @@
1
- import type { ShikiTransformer } from 'shiki';
2
- export interface ITransformerLineNumberOptions {
3
- classActivePre?: string;
4
- classActiveLine?: string;
5
- }
6
- export declare const SHIKI_TRANSFORMER_LINE_NUMBER = "shiki-transformer:line-number";
7
- export declare function createTransformerLineNumber(options?: ITransformerLineNumberOptions): ShikiTransformer;
@@ -1,13 +0,0 @@
1
- export const SHIKI_TRANSFORMER_LINE_NUMBER = 'shiki-transformer:line-number';
2
- export function createTransformerLineNumber(options = {}) {
3
- const { classActiveLine = 'line-number', classActivePre = 'has-line-number', } = options;
4
- return {
5
- name: SHIKI_TRANSFORMER_LINE_NUMBER,
6
- pre(pre) {
7
- return this.addClassToHast(pre, classActivePre);
8
- },
9
- line(node) {
10
- this.addClassToHast(node, classActiveLine);
11
- },
12
- };
13
- }