diff --git a/docs-website/generateDocsDir.ts b/docs-website/generateDocsDir.ts index eabc8b50d7..ff5ec8c0fd 100644 --- a/docs-website/generateDocsDir.ts +++ b/docs-website/generateDocsDir.ts @@ -416,8 +416,15 @@ function markdown_process_inline_directives( filepath: string ): void { const new_content = contents.content.replace( - /^{{\s+inline\s+(\S+)\s+(show_path_as_comment\s+)?\s*}}$/gm, - (_, inline_file_path: string, show_path_as_comment: string) => { + /^(\s*){{(\s*)inline\s+(\S+)(\s+)(show_path_as_comment\s+)?(\s*)}}$/gm, + ( + _, + indent: string, + __, + inline_file_path: string, + ___, + show_path_as_comment: string + ) => { if (!inline_file_path.startsWith("/")) { throw new Error(`inline path must be absolute: ${inline_file_path}`); } @@ -432,9 +439,14 @@ function markdown_process_inline_directives( // that can be used to limit the inlined content to a specific range of lines. let new_contents = ""; if (show_path_as_comment) { - new_contents += `# Inlined from ${inline_file_path}\n`; + new_contents += `${indent}# Inlined from ${inline_file_path}\n`; } - new_contents += referenced_file; + + // Add indentation to each line of the referenced file + new_contents += referenced_file + .split("\n") + .map((line) => `${indent}${line}`) + .join("\n"); return new_contents; }