Skip to content

Commit

Permalink
A little over eager
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Apr 15, 2024
1 parent 4c6ea4a commit 1861aee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion rfd-data/src/content/asciidoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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"))
}

Expand Down
6 changes: 5 additions & 1 deletion rfd-data/src/content/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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> {
Expand Down

0 comments on commit 1861aee

Please sign in to comment.