Skip to content

Commit 2e85c90

Browse files
authored
Fix script bugs (TraceMachina#1147)
1 parent 0e265dc commit 2e85c90

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

docs/scripts/md_to_mdx.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import remarkStringify from "remark-stringify";
1515
import { visit } from "unist-util-visit";
1616

1717
const DEFAULT_TITLE = "Default Title";
18-
const BLOCK_TYPES = ["warning", "note", "tip"];
18+
const BLOCK_TYPES = ["caution", "note", "tip"];
1919

2020
export function parseMarkdown(markdown: string): Root {
2121
return remark().use(remarkParse).parse(markdown) as Root;
@@ -98,6 +98,7 @@ function transformBlockquote(blockquote: Blockquote): RootContent | null {
9898
const cleanedContentText = cleanBlockTypeFromContent(
9999
contentText,
100100
blockType,
101+
firstText.match(/^\[\!(\w+)\]/)?.[1] || "",
101102
);
102103

103104
return {
@@ -111,7 +112,11 @@ function transformBlockquote(blockquote: Blockquote): RootContent | null {
111112
function extractBlockType(firstText: string): string | null {
112113
const match = firstText.match(/^\[\!(\w+)\]/);
113114
if (match?.[1]) {
114-
const blockType = match[1].toLowerCase();
115+
let blockType = match[1];
116+
if (blockType.toUpperCase() === "WARNING") {
117+
blockType = "caution";
118+
}
119+
blockType = blockType.toLowerCase();
115120
if (BLOCK_TYPES.includes(blockType)) {
116121
return blockType;
117122
}
@@ -146,8 +151,12 @@ function extractBlockquoteContent(blockquote: Blockquote): string {
146151
function cleanBlockTypeFromContent(
147152
contentText: string,
148153
blockType: string,
154+
originalBlockType: string,
149155
): string {
150-
return contentText.replace(`[!${blockType.toUpperCase()}]`, "").trim();
156+
return contentText
157+
.replace(`[!${blockType.toUpperCase()}]`, "")
158+
.replace(`[!${originalBlockType.toUpperCase()}]`, "")
159+
.trim();
151160
}
152161

153162
export function preserveInlineCode(content: RootContent[]): RootContent[] {

docs/scripts/metaphase.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ const generateTypeDescription = (type: Type): string => {
333333
case "Box":
334334
return `(box of ${getInnerType(0)})`;
335335
case "String":
336-
return "(String)";
336+
return "";
337337
case "HashMap":
338338
return `(list of objects ${getInnerType(0)}: ${getInnerType(1)})`;
339339
default: {
@@ -546,6 +546,11 @@ title: NativeLink Configuration
546546
description: The NativeLink Configuration Reference
547547
---
548548
549+
:::caution
550+
This page is auto-generated and may contain some minor formatting errors.
551+
If you find any, please feel free to open an issue in our [open-source repository](https://github.com/TraceMachina/nativelink/issues).
552+
:::
553+
549554
This page documents the configuration options for NativeLink.
550555
551556
`;

0 commit comments

Comments
 (0)