This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
md-pdf-rs/src/processors/strip_blank.rs

18 lines
503 B
Rust

use std::char;
use config::Config;
fn remove_blank_lines(line: &&str) -> bool {
if line.is_empty() {
return false;
}
let whitespace_chars: Vec<&str> = line.matches(char::is_whitespace).collect();
if whitespace_chars.len() == line.len() {
return false;
}
return true;
}
pub fn strip_blank(config: Config, input: String) -> Result<String, String> {
let split: Vec<&str> = input.lines().filter(remove_blank_lines).collect();
return Ok(split.join("\n"));
}