Lucas_Werkmeister_WMDE added a comment.
There is a possible workaround we can apply. The `Linker` tells us whether
there’s any comment text before or after the autocomment currently being
formatted, and since as far as I’m aware we only ever use autocomments at the
very beginning of the summary, we can skip all others when formatting:
diff --git a/repo/RepoHooks.php b/repo/RepoHooks.php
index 71dcf27da..16cd20ca2 100644
--- a/repo/RepoHooks.php
+++ b/repo/RepoHooks.php
@@ -694,6 +694,11 @@ public static function onFormat( &$comment, $pre,
$auto, $post, $title, $local )
return;
}
+ if ( $pre ) {
+ $comment = '/* ' . $auto . ' */';
+ return;
+ }
+
$namespaceLookup =
WikibaseRepo::getDefaultInstance()->getEntityNamespaceLookup();
$entityType = $namespaceLookup->getEntityType(
$title->getNamespace() );
if ( $entityType === null ) {
(Setting `$comment` skips `Linker::formatAutocomments`’s usual logic, which
would otherwise turn this into a normal, hyperlinked autocomment.) This doesn’t
quite faithfully preserve the label/description/alias –
`Linker::formatAutocomments`’s regex allows any amount of whitespace, including
none at all, within the `/* … */`, whereas we reconstruct a single space on
each side – but since the output is HTML anyways, it barely makes a difference.
On the other hand, `RepoHooks::onFormat` and `AutoCommentFormatter`
apparently take great care to handle the `$pre` case correctly, so I’m
skeptical if we can really throw that part away and skip formatting of such
autocomments. Do we use additional or non-initial autocomments anywhere?
TASK DETAIL
https://phabricator.wikimedia.org/T186035
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Lucas_Werkmeister_WMDE
Cc: WMDE-leszek, thiemowmde, Lydia_Pintscher, Lucas_Werkmeister_WMDE, Aklapper,
alaa_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, Jayprakash12345, QZanden,
LawExplorer, _jensen, rosalieper, Izno, Wikidata-bugs, aude, Dinoguy1000,
Mbch331, Jay8g
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs