Skip to content

Commit a568851

Browse files
committed
Merge pull request #167 from thephpleague/remove-unnecessary-trim
Remove unnecessary trim from ListItemRenderer
2 parents c894a3b + 051f5f5 commit a568851

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
2020
- Changed tab/indentation handling to meet the new spec behavior
2121
- Modified spec tests to show spaces and tabs in test results
2222
- Replaced `HtmlRendererInterface` with `ElementRendererInterface` (#141)
23+
- Removed the unnecessary `trim()` and string cast from `ListItemRenderer`
2324

2425
### Fixed
2526
- Fixed link reference definition edge case (#120)

src/Block/Renderer/ListItemRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ public function render(AbstractBlock $block, ElementRendererInterface $htmlRende
4949

5050
$li = new HtmlElement('li', $attrs, $contents);
5151

52-
return trim($li);
52+
return $li;
5353
}
5454
}

tests/unit/Block/Renderer/ListItemRendererTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use League\CommonMark\Block\Element\ListData;
1818
use League\CommonMark\Block\Element\ListItem;
1919
use League\CommonMark\Block\Renderer\ListItemRenderer;
20+
use League\CommonMark\HtmlElement;
2021
use League\CommonMark\Tests\Unit\FakeHtmlRenderer;
2122

2223
class ListItemRendererTest extends \PHPUnit_Framework_TestCase
@@ -39,8 +40,9 @@ public function testRenderUnorderedList()
3940

4041
$result = $this->renderer->render($block, $fakeRenderer);
4142

42-
$this->assertInternalType('string', $result);
43-
$this->assertContains('<li id="::escape::id">::blocks::</li>', $result);
43+
$this->assertTrue($result instanceof HtmlElement);
44+
$this->assertEquals('li', $result->getTagName());
45+
$this->assertEquals('<li id="::escape::id">::blocks::</li>', $result->__toString());
4446
}
4547

4648
/**

0 commit comments

Comments
 (0)