fn strip_excessive_newlines(&self, content: &str) -> String {
        if content.is_empty() {
            return content.to_string();
        }

        let pattern = format!(r"\n{{{},}}", self.max_consecutive_newlines + 1);
        let re = Regex::new(&pattern).unwrap();
        let replacement = "\n".repeat(self.max_consecutive_newlines);

        re.replace_all(content, replacement.as_str()).to_string()
    }
Strip excessive consecutive newlines from content

Reduces any sequence of more than max_consecutive_newlines to exactly
max_consecutive_newlines
crates/forge_display/src/markdown.rs