mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "Refactor newline logic for auto-generated <references> sections"
This commit is contained in:
commit
e584c5cf3f
|
@ -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 : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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>'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue