mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-02 03:39:03 +00:00
docs: update markdown_process_inline_directive to work with indentations (#13590)
This commit is contained in:
parent
a02d31c604
commit
76e952f4ac
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user