fixed u strings
@@ -1894,15 +1894,29 @@ pub fn str_content(
})
}
- let mut lines = out_str.lines().filter(|line| line.len() > 0);
+ let mut lines = out_str
+ .lines()
+ .map(|line| line.trim_end())
+ .skip_while(|elem| elem.is_empty()); // removes the newlines at the beginning
- let min_indent = lines.clone().map(|line| line.chars().take_while(|a| *a == ' ').count()).min().unwrap_or_else(|| unreachable!());
+ if lines.clone().filter(|line| line.len() > 0).count() > 0 {
+ let min_indent = lines.clone()
+ .filter(|line| line.len() > 0)
+ .map(|line| line.chars().take_while(|a| *a == ' ').count())
+ .min().unwrap_or_else(|| unreachable!());
while let Some(line) = lines.next() {
- if line.chars().take(min_indent).all(|c| c == ' ') {
+ if line.len() >= min_indent {
out.0 += &format!("{}\n", &line[min_indent..]);
+ } else {
+ out.0 += "\n";
+ }
}
+ } else {
+ out.0 += "\n";
}
+
+ out.0 = out.0.trim_end().to_string(); // removes the newlines at the end
}
_ => {
return Err(SyntaxError::SyntaxError {
