Merge "Refactor newline logic for auto-generated <references> sections"

This commit is contained in:
jenkins-bot 2021-07-30 14:17:49 +00:00 committed by Gerrit Code Review
commit e584c5cf3f
2 changed files with 7 additions and 7 deletions

View file

@ -513,9 +513,9 @@ class Cite {
$s = '';
foreach ( $this->referenceStack->getGroups() as $group ) {
if ( $group === self::DEFAULT_GROUP || $isSectionPreview ) {
$s .= "\n" . $this->formatReferences( $parser, $group );
$s .= $this->formatReferences( $parser, $group );
} else {
$s .= "\n<br />" . $this->errorReporter->halfParsed(
$s .= '<br />' . $this->errorReporter->halfParsed(
$parser,
'cite_error_group_refs_without_references',
Sanitizer::safeEncodeAttribute( $group )
@ -532,13 +532,13 @@ class Cite {
) . $s;
}
// provide a preview of references in its own section
$s = "\n" . Html::rawElement(
$s = Html::rawElement(
'div',
[ 'class' => 'mw-ext-cite-cite_section_preview_references' ],
$s
);
}
return $s;
return $s !== '' ? "\n" . $s : '';
}
/**

View file

@ -68,14 +68,14 @@ class CiteIntegrationTest extends \MediaWikiIntegrationTestCase {
'Default group' => [
[ '' => [ [ 'name' => 'a' ] ] ],
false,
"\n" . '<references />'
"\n<references />"
],
'Default group in preview' => [
[ '' => [ [ 'name' => 'a' ] ] ],
true,
"\n" . '<div class="mw-ext-cite-cite_section_preview_references">' .
'<h2 id="mw-ext-cite-cite_section_preview_references_header">' .
'(cite_section_preview_references)</h2>' . "\n" . '<references /></div>'
'(cite_section_preview_references)</h2><references /></div>'
],
'Named group' => [
[ 'foo' => [ [ 'name' => 'a' ] ] ],
@ -87,7 +87,7 @@ class CiteIntegrationTest extends \MediaWikiIntegrationTestCase {
true,
"\n" . '<div class="mw-ext-cite-cite_section_preview_references">' .
'<h2 id="mw-ext-cite-cite_section_preview_references_header">' .
'(cite_section_preview_references)</h2>' . "\n" . '<references /></div>'
'(cite_section_preview_references)</h2><references /></div>'
]
];
}