From 2e85c9078d0eb9046a26df009aa022bff9039153 Mon Sep 17 00:00:00 2001 From: Blake Hatch Date: Fri, 12 Jul 2024 01:42:08 -0400 Subject: [PATCH] Fix script bugs (#1147) --- docs/scripts/md_to_mdx.ts | 15 ++++++++++++--- docs/scripts/metaphase.ts | 7 ++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/scripts/md_to_mdx.ts b/docs/scripts/md_to_mdx.ts index 13cbfed9e..6dc39be40 100644 --- a/docs/scripts/md_to_mdx.ts +++ b/docs/scripts/md_to_mdx.ts @@ -15,7 +15,7 @@ import remarkStringify from "remark-stringify"; import { visit } from "unist-util-visit"; const DEFAULT_TITLE = "Default Title"; -const BLOCK_TYPES = ["warning", "note", "tip"]; +const BLOCK_TYPES = ["caution", "note", "tip"]; export function parseMarkdown(markdown: string): Root { return remark().use(remarkParse).parse(markdown) as Root; @@ -98,6 +98,7 @@ function transformBlockquote(blockquote: Blockquote): RootContent | null { const cleanedContentText = cleanBlockTypeFromContent( contentText, blockType, + firstText.match(/^\[\!(\w+)\]/)?.[1] || "", ); return { @@ -111,7 +112,11 @@ function transformBlockquote(blockquote: Blockquote): RootContent | null { function extractBlockType(firstText: string): string | null { const match = firstText.match(/^\[\!(\w+)\]/); if (match?.[1]) { - const blockType = match[1].toLowerCase(); + let blockType = match[1]; + if (blockType.toUpperCase() === "WARNING") { + blockType = "caution"; + } + blockType = blockType.toLowerCase(); if (BLOCK_TYPES.includes(blockType)) { return blockType; } @@ -146,8 +151,12 @@ function extractBlockquoteContent(blockquote: Blockquote): string { function cleanBlockTypeFromContent( contentText: string, blockType: string, + originalBlockType: string, ): string { - return contentText.replace(`[!${blockType.toUpperCase()}]`, "").trim(); + return contentText + .replace(`[!${blockType.toUpperCase()}]`, "") + .replace(`[!${originalBlockType.toUpperCase()}]`, "") + .trim(); } export function preserveInlineCode(content: RootContent[]): RootContent[] { diff --git a/docs/scripts/metaphase.ts b/docs/scripts/metaphase.ts index 853f00dd2..a7d1247cc 100644 --- a/docs/scripts/metaphase.ts +++ b/docs/scripts/metaphase.ts @@ -333,7 +333,7 @@ const generateTypeDescription = (type: Type): string => { case "Box": return `(box of ${getInnerType(0)})`; case "String": - return "(String)"; + return ""; case "HashMap": return `(list of objects ${getInnerType(0)}: ${getInnerType(1)})`; default: { @@ -546,6 +546,11 @@ title: NativeLink Configuration description: The NativeLink Configuration Reference --- +:::caution +This page is auto-generated and may contain some minor formatting errors. +If you find any, please feel free to open an issue in our [open-source repository](https://github.com/TraceMachina/nativelink/issues). +::: + This page documents the configuration options for NativeLink. `;