Template talk:Visible anchor/Archive 1

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

text parameter

What's the point of the text parameter? Instead of {{Visible anchor|foo|text=bar}}, it sounds like one should write {{Anchor|foo}}bar instead. Amirite? --Bxj (talk) 03:17, 29 October 2011 (UTC)

Because the visible text should be contained within the anchor. Edokter (talk) — 08:13, 29 October 2011 (UTC)
Why "should"? Is there any functional or visible problem it's addressing? Seems like it's a longer and more obscure way of coding something, hence it wouldn't be used (and not needed). --Bxj (talk) 18:12, 29 October 2011 (UTC)
If you're going to make a text part of the anchor, it needs to be inside the span. Placing it outside may appear to work, but it would not be part of the anchor. Edokter (talk) — 22:18, 29 October 2011 (UTC)

Where to use the {{visible anchor}}?

I have started a discussion about that issue:

I think we should recommend:

  • use it for redirection to the beginning of a sub-section (e.g. in the sentence presenting a diagram/picture or a code example, or as I did for the above link)
  • do not use it in the middle of the text because the reader expects to see the section title

What should be the usage recommendation? Oliver H (talk) 16:20, 28 September 2012 (UTC)

Edit request: inaccurate error message

The code

<span class="error">[[Template:Anchor]] (or Anchors): too many anchors, maximum is 10.</span>

should instead read

 <span class="error">[[Template:Visible anchor]]: too many anchors, maximum is 10.</span>

I've put a space just before the span so that the error message doesn't have to butt up against the anchor text as in

example-aTemplate:Anchor (or Anchors): too many anchors, maximum is 10.

Many thanks, User:GKFXtalk 18:58, 7 January 2018 (UTC).

Done — JJMC89(T·C) 19:00, 7 January 2018 (UTC)

Improving visuals for visual anchor

Hey! I was just wondering if we have any opinions on improving the visuals of {{Visible anchor}}. Instead of just displaying the text, what about if we added parameter (|display= etc) that made it a bit nicer:

You can wikilink to this point in the page with with [[#anchor|...]].

ItsPugle (please ping on reply) 09:09, 10 November 2020 (UTC)

@JJMC89 and Vadmium: Thoughts? Sorry if you're not interested, I just grabbed your username from the template's most recent edits. ItsPugle (please ping on reply) 09:48, 11 November 2020 (UTC)

Requested move 4 December 2020

The following is a closed discussion of a requested move. Please do not modify it. Subsequent comments should be made in a new section on the talk page. Editors desiring to contest the closing decision should consider a move review after discussing it on the closer's talk page. No further edits should be made to this discussion.

The result of the move request was: not moved. (closed by non-admin page mover) Jerm (talk) 01:38, 11 December 2020 (UTC)


Template:Visible anchorTemplate:Text anchor – Is this more concise name preferable? I cannot move the template because it is protected. JsfasdF252 (talk) 00:06, 4 December 2020 (UTC)

  • @JsfasdF252: Hello again! You seem to have an unerring ability to find the pages on my watchlist. Are you aware that you could just create a redirect from “Template:Text anchor” to here without moving anything? That is the normal approach taken to having a range of names to satisfy what different editors think is logical. I would recommend against moving templates when the creation of a redirect would do. User:GKFXtalk 00:40, 4 December 2020 (UTC)
  • How about moving this template to Template:Text anchor, and redirecting Template:Visible anchor to that? I think I prefer the more concise name, but I would hate to be overly disruptive. ItsPugle (please ping on reply) 06:21, 7 December 2020 (UTC)
  • Oppose The proposed name is ambiguous. — JJMC89(T·C) 05:36, 8 December 2020 (UTC)
  • Oppose. This template is similar to {{Anchor}}, which is "invisible", so "Visible anchor" is the best name for this template. There is such a thing as "too concise", I think, which just means "less precise and more ambiguous". A shortcut redirect from the proposed target is a good idea, though. P.I. Ellsworth  ed. put'r there 08:52, 8 December 2020 (UTC)

The discussion above is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.

Template-protected edit request on 7 December 2020

Just wondering if #Improving visuals for visual anchor could be actioned, as there has been almost a month of WP:SILENCE. This can be actioned per the code on Template:Visible anchor/sandbox and demonstrated on Template:Visible anchor/testcases#display. ItsPugle (please ping on reply) 06:18, 7 December 2020 (UTC)

Template:Visible anchor/testcases#Tests are not correct for the sandbox. — JJMC89(T·C) 06:58, 7 December 2020 (UTC)
@JJMC89: Fixed. I literally just forgot one pipe in a variable name. ItsPugle (please ping on reply) 07:37, 7 December 2020 (UTC)
This template is extensively used in mainspace articles. I've used it to visibly anchor part of a section header to fix broken links. I tested this in the George Claghorn article in preview, and here is what I saw:
Section header was == Military career ==
code was == Military {{Visible anchor/sandbox|career|display=yes}} ==, and the result was:
Military       You can wikilink to this point in the page with with [[#career]] or [[page name#career]].
Checked it also in running text. In the next section, 3rd paragraph, there is the partial sentence:
named by President George Washington after the Constitution of the United States of America
so I vanchored "President":
named by {{Visible anchor/sandbox|President|display=yes}} George Washington after the Constitution of the United States of America
the result was:
named by       You can wikilink to this point in the page with with [[#President]] or [[page name#President]]. George Washington after the Constitution of the United States of America
The |display=yes parameter could never be used in article space, and I'm not sure it should be used in any namespace. What am I missing? Where is the application for this "improved visual" of the {{Visible anchor}} template? P.I. Ellsworth  ed. put'r there 17:58, 8 December 2020 (UTC)
To editors ItsPugle and JJMC89:  Not done for now: please establish a consensus for this alteration before using the {{edit template-protected}} template. P.I. Ellsworth  ed. put'r there 12:40, 11 December 2020 (UTC)
I think this is probably too editor-specific to justify putting into articles and making visible to readers. It would be great feature as a gadget or something (perhaps putting an icon into the left-hand margin with the Vector skin). User:GKFXtalk 21:27, 11 December 2020 (UTC)

Template-protected edit request on 14 May 2021

Replace the contents of the template with Template:Visible anchor/sandbox replacing "Template:Visible anchor/sandbox/styles.css" with "Template:Visible anchor/styles.css" and move Template:Visible anchor/sandbox/styles.css to Template:Visible anchor/styles.css. The changes make it so the anchor is highlighted when it is linked to in the URL. For example when #Foo is clicked Foo will be highlighted. This makes it easier to find the relevant content when a redirect links to a visible anchor. BrandonXLF (talk) 15:21, 14 May 2021 (UTC)

Your suggested highlight colour, #eaf3ff, is effectively white and so is near-invisible when used to highlight a single word. Could I suggest something slightly more exciting like box-shadow:0 0 3px 1.7px rgba(50,50,50,0.3) or just a darker background color rgba(50, 50, 200, 0.15)? User:GKFXtalk 21:44, 14 May 2021 (UTC)
I made it #b1d2ff by making it a little less white. BrandonXLF (talk) 00:47, 15 May 2021 (UTC)
 Done * Pppery * it has begun... 14:29, 16 May 2021 (UTC)

Allow more anchors

Here is an example where there were not enough anchors available; that page has up to 14 anchors in one (the current limit is 10). I've increased the limit to 20 on the sandbox, which should hopefully be enough for the forseeable future, although maybe the limit could be eliminated with Template:For loop? ―Jochem van Hees (talk) 13:00, 22 March 2022 (UTC)

@Jochem van Hees: You don't need to go that far. 14 visible anchors is about 12 too many in any case. --Redrose64 🌹 (talk) 16:23, 22 March 2022 (UTC)
Why? Those anchors are already there, and probably all have incoming links. Why should they be removed? ―Jochem van Hees (talk) 16:27, 22 March 2022 (UTC)
I see no reason that you can't use {{anchor}} (which has unlimited parameters) to supply the extra ones. So for the case with 14 anchors (do you really need that many), instead of
# {{visible anchor|soap5|Soap5|SOAP5|ADVERTISING|MARKETING|PR|ADVERT|COMMERCIAL|PROMOCORP|GARAGE|PUBLICRELATIONS|PUBLIC RELATIONS|PUBLICITY|Advertising, marketing or public relations|text='''Advertising, marketing or public relations.'''}}
you could use
# {{anchor|soap5|Soap5|SOAP5|ADVERTISING|MARKETING|PR|ADVERT|COMMERCIAL|PROMOCORP|GARAGE|PUBLICRELATIONS|PUBLIC RELATIONS|PUBLICITY}}{{visible anchor|Advertising, marketing or public relations|text='''Advertising, marketing or public relations.'''}}
One of the features of {{Visible anchor}} over {{anchor}} is that one of the anchors (the first one) is visible; but when you use the |text= parameter, that benefit is defeated. --Redrose64 🌹 (talk) 17:17, 22 March 2022 (UTC)
 Not done Insufficient consensus to implement. * Pppery * it has begun... 19:49, 22 March 2022 (UTC)
@Pppery: I don't quite think 6h 49m is enough time to allow people to reasonably engage with this discussion and to conclude that there is no consensus. Would you be okay for the discussion continue for a couple days or so (or at least be open for that time), and if there's no consensus by then, this is something that we can refer to WP:RFC if the OP wishes? Tim (Talk to me) 00:03, 23 March 2022 (UTC)
From what I understand, the edit request should not be active if there is still ongoing discussion, because otherwise it looks like there's something for template editors to do right now. It can be reactivated when there is consensus. ―Jochem van Hees (talk) 00:17, 23 March 2022 (UTC)
Indeed, that's what I meant. I have no objection to any discussion continuing, and my {{not done}} was referring to the {{Edit template-protected}} request at the top, which is an immiedate request for attention that shouldn't languish while discussion is ongoing (but in practice it often does). * Pppery * it has begun... 00:51, 23 March 2022 (UTC)
@Redrose64: That's not the only thing this template does though, it also highlights the text when it is linked to. I think that is a big benefit over just using {{anchor}}, especially on policy pages, because you can actually see where someone wants to direct your attention to. ―Jochem van Hees (talk) 20:00, 22 March 2022 (UTC)
@Jochem van Hees, that might be something to change in {{anchor}}, then. Qwerfjkltalk 10:49, 18 April 2022 (UTC)

Template-protected edit request on 6 August 2023

I'm requesting the addition of an optional |lang= parameter, in order to allow language markup to the visible anchor. The value of the |lang= parameter should be an ISO 639 language code, just like as used in the {{lang}} template. I have implemented the desired change in the template sandbox (Sbb addition to {{visible anchor/sandbox}}, which just calls {{lang}} (with |italic=unset) if the |lang= parameter is defined. More complicated uses of {{lang}}-style formatting and options are beyond the scope of this change. They would require specifically using {{vanchor}}'s |text= parameter, and explicitly invoking the {{lang}} template with desired parameters.

The example usage would be something like: {{vanchor|lang=en-US|polarizer|polarizing filter}}, which results in something like the following (simplified) HTML:

<span class="vanchor">
  <span id="polarizer"></span>
  <span id="polarizing_filter"></span>
  <span class="vanchor-text">
    <span title="American English-language text">
      <span lang="en-US">polarizer</span>
    </span>
  </span>
</span>

Compare how to achieve even just a single language–marked-up anchor without this parameter, vs. with this parameter:

Without
{{lang |en-US |polarizer}} {{anchor |polarizer}}
{{vanchor |text= {{lang |en-US |polarizer}} |polarizer}}
With
{{vanchor |lang= en-US |polarizer}}  — sbb (talk) 22:21, 6 August 2023 (UTC)
Sbb, so the purpose is to bypass adding {{lang}} as the displayed text? SWinxy (talk) 19:52, 12 August 2023 (UTC)
Yes, to just apply the language code to the <span>...</span> to the displayed text.  — sbb (talk) 22:00, 12 August 2023 (UTC)
I guess I could understand putting the lang HTML tag in the spans ourselves, but for this implementation of wrapping the text in the lang template, I don't get how it might be in the scope of this template SWinxy (talk) 22:48, 12 August 2023 (UTC)
 Completed. Please update the documentation page (/doc) as needed. P.I. Ellsworth , ed. put'er there 13:37, 19 August 2023 (UTC)
This change caused display and Linter errors when the content of the template was two asterisks. See the "Testing asterisk content" section of the testcases page. I have put some modified code in the sandbox that puts the proposed |lang= parameter value directly into the span tag. Does that meet the need expressed above? – Jonesey95 (talk) 15:28, 19 August 2023 (UTC)
It's passable as a solution, but I'd prefer if it invoked/took advantage of Module:Lang. I'm sure my original suggestion could be improved with Invoke: (although I'm not versed in that usage at all).
Downsides of your implementation:
  • No ISO language code error checking, as is done with {{lang}}
  • Doesn't parse the language code to apply the <span title="ZZZ-language text"> title attribute, which is visible as hover text.
Regarding the use-case your implementation ameliorates, in my limited debugging/testing, it seems the problem is applying the string "**" (perhaps "[*]{2,}"?) to the |text= parameter of the {{lang}} template, I believe? (Yes, very weasel-worded. I'm not strongly confident in that assertion).
In the John Calipari case (and similar), I'd argue that {{efn}} + {{notelist}} for the table footnotes are better implementations. On the other hand, contradicting myself, that shouldn't dictate how editors choose to markup table notes/footnotes; I'm aware of that. I'm a rusty on WP regex searches, but I'll try to get an idea of how many articles would be impacted going with my original (or functionally similar) suggestion.  — sbb (talk) 03:24, 29 August 2023 (UTC)