pub fn remove_consecutive_spaces(file_contents: String) -> Result<String>Expand description
Remove consecutive spaces on lines that begin with a dash, keeping leading spaces
§Arguments
file_contents: Contents of a file as a string
returns: Result<String, ()>
§Examples
use logseq::remove_consecutive_spaces;
assert_eq!(remove_consecutive_spaces(" abc 123 def ".to_string()).unwrap(), " abc 123 def ".to_string());
assert_eq!(remove_consecutive_spaces("\n - abc 123\n - def 4 5 ".to_string()).unwrap(), "\n - abc 123\n - def 4 5 ".to_string());
assert_eq!(remove_consecutive_spaces(
" -This is a test\n Another test\n- Dash line here".to_string()).unwrap(),
" -This is a test\n Another test\n- Dash line here".to_string());
assert_eq!(remove_consecutive_spaces(
" - This is a test\n Another test\n- Dash line here with extra spaces".to_string()).unwrap(),
" - This is a test\n Another test\n- Dash line here with extra spaces".to_string());
let ends_with_linebreak = "- Root\n - Child\n";
assert_eq!(remove_consecutive_spaces(ends_with_linebreak.to_string()).unwrap(), ends_with_linebreak);