Skip to content

Commit c0bb0fa

Browse files
committed
Work on more author fallback parsing
1 parent 5fd5611 commit c0bb0fa

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

rfd-processor/src/content/asciidoc.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,22 @@ impl<'a> RfdAttributes for RfdAsciidoc<'a> {
206206
if first_line == "{authors}" {
207207
self.attr("authors")
208208
} else {
209-
Some(first_line)
209+
210+
// Given that we are in a fallback case we need to be slightly picky on what
211+
// lines we allow. We require that the line at least include a *@*.* word to
212+
// try and filter out lines that are not actually author lines
213+
let author_fallback_pattern = Regex::new(r"^.*?([\S]+@[\S]+.[\S]+).*?$").unwrap();
214+
let fallback_matches = author_fallback_pattern.is_match(first_line);
215+
216+
if fallback_matches {
217+
Some(first_line)
218+
} else {
219+
220+
// If none of our attempts have found an author, we drop back to the
221+
// attribute lookup. Eventually all of this logic should be removed and only
222+
// the attribute version should be supported
223+
self.attr("authors")
224+
}
210225
}
211226
})
212227
})
@@ -297,6 +312,26 @@ sdf"#;
297312
assert_eq!(expected, authors);
298313
}
299314

315+
#[test]
316+
fn test_get_asciidoc_attribute_authors_without_marker() {
317+
let content = r#":showtitle:
318+
:toc: left
319+
:numbered:
320+
:icons: font
321+
:state: published
322+
:revremark: State: {state} | {discussion}
323+
:authors: firstname <email@company>
324+
325+
= RFD 123 Test Rfd
326+
327+
dsfsdfdsfsdfdsfsdfdsfsdfdsfsdfdsfsdfdsfsdfdsfsdfdsfsdfdsfsdfdsfsdf
328+
"#;
329+
let rfd = RfdContent::new_asciidoc(content);
330+
let authors = rfd.get_authors().unwrap();
331+
let expected = r#"firstname <email@company>"#.to_string();
332+
assert_eq!(expected, authors);
333+
}
334+
300335
#[test]
301336
fn test_get_asciidoc_attribute_authors_with_markdown_sections() {
302337
let content = r#"

0 commit comments

Comments
 (0)