Skip to content

Commit

Permalink
Fix bug in SplitText directive
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Feb 14, 2018
1 parent 677acf2 commit 27d87f6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/render/apply/split_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,7 @@ impl Action for SplitText {
for (num, line) in src.lines().enumerate() {
let num = num+1;
let line = line.map_err(Error::IoError)?;
if file.is_none() {
if !line.trim().is_empty() {
return Err(Error::FormatError(format!(
"Error splitting file: \
Non-empty line {} before title", num)));
}
} else if let Some(capt) = self.section.captures(&line) {
if let Some(capt) = self.section.captures(&line) {
let sect = capt.get(1).map(|x| x.as_str()).unwrap_or("");
if !self.validate.is_match(sect) {
return Err(Error::FormatError(format!(
Expand All @@ -114,6 +108,12 @@ impl Action for SplitText {
file = Some(BufWriter::new(open_file(&dest, sect)?));
name = Some(sect.to_string());
visited.insert(sect.to_string());
} else if file.is_none() {
if !line.trim().is_empty() {
return Err(Error::FormatError(format!(
"Error splitting file: \
Non-empty line {} before title", num)));
}
} else {
writeln!(&mut file.as_mut().unwrap(), "{}", line)
.map_err(|e| Error::IoError(e))?;
Expand Down

0 comments on commit 27d87f6

Please sign in to comment.