Skip to content

Commit

Permalink
[BUGFIX] Remove whitespace and duplicate empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Sep 6, 2024
1 parent 6a8afce commit c55b0b7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/Util/CodeSnippetCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ public static function writeFile(array $entry, String $content, String $rstConte
throw new InvalidConfigurationException('No content found for file ' . $entry['targetFileName']);
}

// Ensure no trailing whitespaces on empty lines
$content = preg_replace("/\n\s*\n/", "\n\n", $content);
// Remove trailing whitespace from lines and ensure no empty lines with only whitespace
$content = preg_replace("/[ \t]+$/m", '', $content); // Removes trailing spaces and tabs from each line

// Remove consecutive empty lines with or without whitespace
$content = preg_replace("/\n{2,}/", "\n\n", $content);

// Ensure content ends with exactly one empty line
$content = trim($content) . "\n";
Expand Down

0 comments on commit c55b0b7

Please sign in to comment.