Do not delete text that fails preformat-balance

If preformat lines are unbalanced, do not delete all the lines from there to
end of file.  That might be the only copy of edits made by the user.

Do not print entire file contents for munge errors affecting entire file.
This commit is contained in:
Eric Tune
2016-01-04 08:43:48 -08:00
parent 9264340338
commit 1ce3081e55
3 changed files with 25 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ func updatePreformatted(filePath string, mlines mungeLines) (mungeLines, error)
// If the file ends on a preformatted line, there must have been an imbalance.
func checkPreformatBalance(filePath string, mlines mungeLines) (mungeLines, error) {
if len(mlines) > 0 && mlines[len(mlines)-1].preformatted {
return nil, fmt.Errorf("file ends in preformatted block")
return mlines, fmt.Errorf("unbalanced triple backtick delimiters")
}
return mlines, nil
}