Skip to content

Commit

Permalink
Merge pull request #22 from cheeZery/fix-unnecessary-empty-lines
Browse files Browse the repository at this point in the history
Fix unnecessary empty lines
  • Loading branch information
cheeZery authored Dec 17, 2018
2 parents 0d6c0e9 + 4832c09 commit 7ad96aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Parser/MarkdownParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public function getDocumentedDependencies(
continue;
}

$currentDependency->getAdditionalContent()->add($line);
// Trim line breaks, because they will be added by the writer
$trimmedLine = trim($line, "\n\r");

$currentDependency->getAdditionalContent()->add($trimmedLine);
}

$this->cleanupAdditionalContent($dependencies);
Expand Down
11 changes: 11 additions & 0 deletions tests/Parser/MarkdownParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function testItParsesDependenciesFileCorrectlyWithoutFilter()
$this->assertNotNull($package);
$this->assertCount(3, $package->getAdditionalContent()->getAll());
$this->assertEquals(['', 'test 1 ', 'test 2'], array_values($package->getAdditionalContent()->getAll()));

$package = $packageList->get('Composer', 'symfony/yaml');
$this->assertNotNull($package);
$this->assertCount(4, $package->getAdditionalContent()->getAll());
$this->assertEquals(['', 'Will leave only one', '', 'consecutive empty line'], array_values($package->getAdditionalContent()->getAll()));
}

public function getValidDependenciesFileData(): string
Expand Down Expand Up @@ -84,6 +89,12 @@ public function getValidDependenciesFileData(): string
## symfony/yaml `v4.1.3` [link](https://packagist.org/packages/symfony/yaml)
> Symfony Yaml Component
Will leave only one
consecutive empty line
## zendframework/zend-servicemanager `3.3.2` [link](https://packagist.org/packages/zendframework/zend-servicemanager)
> Factory-Driven Dependency Injection Container
Expand Down

0 comments on commit 7ad96aa

Please sign in to comment.