diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index 8e2001e2e5..ba05d072df 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -281,7 +281,8 @@ protected function printCodeComparisonBlock(DOMNode $node) { $codeBlocks = $node->getElementsByTagName('code'); - $firstTitle = $codeBlocks->item(0)->getAttribute('title'); + $firstTitle = trim($codeBlocks->item(0)->getAttribute('title')); + $firstTitle = str_replace(' ', '  ', $firstTitle); $first = trim($codeBlocks->item(0)->nodeValue); $first = str_replace('', $first); @@ -289,7 +290,8 @@ protected function printCodeComparisonBlock(DOMNode $node) $first = str_replace('', '', $first); $first = str_replace('', '', $first); - $secondTitle = $codeBlocks->item(1)->getAttribute('title'); + $secondTitle = trim($codeBlocks->item(1)->getAttribute('title')); + $secondTitle = str_replace(' ', '  ', $secondTitle); $second = trim($codeBlocks->item(1)->nodeValue); $second = str_replace('', $second); diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index eb51b60c77..55ef3972bf 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -160,13 +160,15 @@ protected function printCodeComparisonBlock(DOMNode $node) { $codeBlocks = $node->getElementsByTagName('code'); - $firstTitle = $codeBlocks->item(0)->getAttribute('title'); + $firstTitle = trim($codeBlocks->item(0)->getAttribute('title')); + $firstTitle = str_replace(' ', '  ', $firstTitle); $first = trim($codeBlocks->item(0)->nodeValue); $first = str_replace("\n", PHP_EOL.' ', $first); $first = str_replace('', '', $first); $first = str_replace('', '', $first); - $secondTitle = $codeBlocks->item(1)->getAttribute('title'); + $secondTitle = trim($codeBlocks->item(1)->getAttribute('title')); + $secondTitle = str_replace(' ', '  ', $secondTitle); $second = trim($codeBlocks->item(1)->nodeValue); $second = str_replace("\n", PHP_EOL.' ', $second); $second = str_replace('', '', $second); diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html index a64cdb4deb..fe1c15bb47 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.html @@ -75,8 +75,8 @@

Code Title, whitespace handling

This is a standard block.

- - + + @@ -85,8 +85,8 @@

Code Title, whitespace handling

Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars. Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars.
// Dummy.
- - + + diff --git a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md index 2d04562c7e..e623ba98dd 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.md @@ -5,8 +5,8 @@ This is a standard block.
Valid: spaces at start + end of description. Invalid: spaces ' ' in description.Valid: spaces at start + end of description.Invalid: spaces '     ' in description.
// Note: description above without the
// trailing whitespace fits in 46 chars.
- - + +
Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars. Valid: spaces at start of description.Invalid: spaces at end making line > 46 chars.
@@ -23,8 +23,8 @@ This is a standard block.
- - + +
Valid: spaces at start + end of description. Invalid: spaces ' ' in description.Valid: spaces at start + end of description.Invalid: spaces '     ' in description.