Page MenuHomePhabricator

DefaultEntityLinkFormatter should make nicer links without a label
Open, LowPublic

Description

DefaultEntityLinkFormatter adds labels to links to entities on special pages and summaries. The HTML usually looks like:

<a href="/wiki/Q12345" class="mw-changeslist-title" title="label | ‎description">
  <span class="wb-itemlink">
    <span class="wb-itemlink-label" dir="dir" lang="lang">label</span> <span class="wb-itemlink-id">(Q12345)</span>
  </span>
</a>

which looks like:
label (Q12345).

If there's no label, the link has HTML like:

<a href="/wiki/Q12345" class="mw-changeslist-title" title="Q12345">
  <span class="wb-itemlink">
    <span class="wb-itemlink-label" dir="dir" lang="lang"></span> <span class="wb-itemlink-id">(Q12345)</span>
  </span>
</a>

and displays: _(Q12345) ("_" is normal space).

Notice that the first nested <span> is empty and the link has unexpected whitespace at the beginning.

I think this should be improved. Several possibilities come to my mind:

  • fill the empty span with a placeholder text like "no label (Q12345)" (modules on Wikidata do this)
  • make the content of wb-itemlink-id the only text of the whole link
  • only show wb-itemlink-id, remove the empty tag

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Lydia_Pintscher moved this task from incoming to ready to go on the Wikidata board.
Lydia_Pintscher added a subscriber: hoo.
matej_suchanek renamed this task from LinkBeginHookHandler should make nicer links without a label to ItemLinkFormatter should make nicer links without a label.Mar 25 2018, 11:09 AM
matej_suchanek updated the task description. (Show Details)
matej_suchanek added a subscriber: Smalyshev.
matej_suchanek renamed this task from ItemLinkFormatter should make nicer links without a label to DefaultEntityLinkFormatter should make nicer links without a label.Sep 13 2019, 12:45 PM
matej_suchanek updated the task description. (Show Details)