Skip to content

Commit

Permalink
Make traverser operation less verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
arranf committed Aug 22, 2019
1 parent 1b28a31 commit 30827d6
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/traverse/traverser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,9 @@ fn process_file(file_location: &FileLocation) -> Result<PageIndex, OperationResu

fn process_md_file(file_location: &FileLocation) -> Result<PageIndex, OperationResult> {
let contents = fs::read_to_string(file_location.absolute_path.to_string())?;
let first_line = contents.lines().find(|&l| !l.trim().is_empty());

// Gets the first non-empty line of the file
let mut first_line = "";
let mut lines = contents.lines();

while let Some(line) = lines.next() {
if !line.trim().is_empty() {
first_line = line;
break;
}
}

match first_line.chars().next() {
match first_line.unwrap_or_default().chars().next() {
Some('+') => process_md_toml_front_matter(&contents, &file_location),
Some('-') => process_md_yaml_front_matter(&contents, &file_location),
// TODO: JSON frontmatter '{' => process_json_frontmatter()
Expand Down

0 comments on commit 30827d6

Please sign in to comment.