From 1861aee36b9f6bf2252517e8d28ba34218a55cbb Mon Sep 17 00:00:00 2001 From: augustuswm Date: Mon, 15 Apr 2024 09:51:52 -0500 Subject: [PATCH] A little over eager --- rfd-data/src/content/asciidoc.rs | 8 +++++++- rfd-data/src/content/markdown.rs | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rfd-data/src/content/asciidoc.rs b/rfd-data/src/content/asciidoc.rs index 07f4457..9fd4235 100644 --- a/rfd-data/src/content/asciidoc.rs +++ b/rfd-data/src/content/asciidoc.rs @@ -49,6 +49,7 @@ impl<'a> RfdAsciidoc<'a> { let body = self.body(); self.content = (header.unwrap_or_default().to_string() + + "\n" + &new_attr + title.as_str() + body.unwrap_or_default()) @@ -139,7 +140,10 @@ impl<'a> RfdDocument for RfdAsciidoc<'a> { } fn header(&self) -> Option<&str> { - self.title_pattern().splitn(&self.content, 2).nth(0) + self.title_pattern() + .splitn(&self.content, 2) + .nth(0) + .map(|s| s.trim_end()) } fn body(&self) -> Option<&str> { @@ -264,7 +268,9 @@ dsfsdf sdf :discussion: nope"#; let mut rfd = RfdAsciidoc::new(content); + println!("Before\n{}", rfd.raw()); rfd.set_attr("xrefstyle", "short"); + println!("After\n{}", rfd.raw()); assert_eq!(Some("short"), rfd.attr("xrefstyle")) } diff --git a/rfd-data/src/content/markdown.rs b/rfd-data/src/content/markdown.rs index 2ef79b7..dc96fe9 100644 --- a/rfd-data/src/content/markdown.rs +++ b/rfd-data/src/content/markdown.rs @@ -48,6 +48,7 @@ impl<'a> RfdMarkdown<'a> { let body = self.body(); self.content = (header.unwrap_or_default().to_string() + + "\n" + &new_attr + title.as_str() + body.unwrap_or_default()) @@ -108,7 +109,10 @@ impl<'a> RfdDocument for RfdMarkdown<'a> { } fn header(&self) -> Option<&str> { - self.title_pattern().splitn(&self.content, 2).nth(0) + self.title_pattern() + .splitn(&self.content, 2) + .nth(0) + .map(|s| s.trim_end()) } fn body(&self) -> Option<&str> {