diff --git a/src/macros/config/file_tree/markdown_representation.rs b/src/macros/config/file_tree/markdown_representation.rs index aaa4fe4..916aba6 100644 --- a/src/macros/config/file_tree/markdown_representation.rs +++ b/src/macros/config/file_tree/markdown_representation.rs @@ -51,28 +51,47 @@ impl Display for Language { impl Display for GeneratedFile { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_fmt(format_args!("File path: `{}`\n", self.path.display()))?; + f.write_fmt(format_args!("File path: `{}`\n\n", self.path.display()))?; f.write_fmt(format_args!("```{}\n", self.language))?; f.write_fmt(format_args!("{}", &self.value))?; - f.write_str("```\n\n") + f.write_str("```") } } impl Display for FileTree { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut first = true; if !self.host_files.is_empty() { - f.write_str("# Host files\n")?; + f.write_str("# Host files\n\n")?; self.host_files .iter() - .map(|file| -> std::fmt::Result { f.write_str(&file.to_string()) }) + .map(|file| -> std::fmt::Result { + if !first { + f.write_str("\n\n")?; + } else { + first = false; + } + f.write_str(&file.to_string()) + }) .collect::()?; } + first = true; if !self.auxiliary_files.is_empty() { - f.write_str("# Auxiliary files\n")?; + if !self.host_files.is_empty() { + f.write_str("\n\n")?; + } + f.write_str("# Auxiliary files\n\n")?; self.auxiliary_files .iter() - .map(|file| -> std::fmt::Result { f.write_str(&file.to_string()) }) + .map(|file| -> std::fmt::Result { + if !first { + f.write_str("\n\n")?; + } else { + first = false; + } + f.write_str(&file.to_string()) + }) .collect::()?; } Ok(())