Syntax errors when multiple citations are nested within this template edit

This template uses {{Wikicite}} to wrap its reference content, which in turn uses <cite>...</cite> tags to wrap its content. The documentation for this template explicitly suggests the use of {{cite book}} and similar Citation Style 1 templates within {{rma}}, but the documentation for {{Wikicite}} explicitly says the opposite: This template is only needed for handwritten citations, or citations using non-standard citation templates.

A problem occurs when this template is used to wrap multiple lines of content, for example:

Put this code into Special:ExpandTemplates:

{{rma| tag=L2 |reference= {{cite book
|last=Luria |first= A. R. |year=1963 |translator=O. L. Zangwill
|title=Restoration of function after brain injury
|location=New York |publisher=Pergamon Press, Macmillan
}}
* {{cite book | author-mask=2
|last=Luria |first= A. R. |year=1973 |translator=Haigh Basil
|title=The working brain: an introduction to neuropsychology
|location=New York |publisher=Basic Books
}}
* {{cite book | author-mask=2
|last=Luria |first= A. R. |year=1979
|title=The making of mind: a personal account of Soviet psychology
| url=https://archive.org/details/makingofmind00luri
| url-access=registration
|publisher=Harvard University Press
|isbn=978-0-674-54326-3 |editor1=Michael Cole |editor2=Sheila Cole
}}
* {{cite book | author-mask=2
|last=Luria |first= A. R. |year=1980 |edition=2nd |translator=Haigh Basil
|title=Higher cortical functions in man
|location=New York |publisher=Basic Books
}}
* {{cite book | author-mask=2
|last=Luria |first= A. R. |year=1972 |translator=Lynn Solotaroff
|title=The man with a shattered world: the history of a brain wound
|publisher=Harvard University Press
}}
}}

When it is expanded, you can see <cite class="citation wikicite" id=L2> at the beginning of the citation text, and </cite> at the end of the citation text. With individual citations enclosed in {{rma}}, that is fine. When there is a bulleted list in between those two tags, however, the parser thinks that the opening tag has no end and the closing tag has no beginning. Hence the Lint errors listed on the "Page information" for that page.

HTML5 semantics require the <cite> tag (and other formatting tags limited to phrasing content, like <span>, <strike>, <em>, <small>, italics and bold, etc.) to be wrapped around individual in-line elements. In this case, {{rma}} is causing <cite>...</cite> to be wrapped around a block element, which is invalid syntax. There may be a better workaround or solution than the one I implemented at that page. I created {{smalldiv}} to allow bulleted lists and similar multi-line content to be wrapped in small formatting, to replace <small>...</small> in those cases; there may be a similar workaround available for {{rma}}.

One resolution might be to stop using {{Wikicite}} within this template. Another might be to use <div>...</div> tags instead of <cite>...</cite> tags within Wikicite. I have not researched to see what either of those changes will break (I assume something).

The particular example above is copied from Phineas Gage. There are other examples at Donald G. Saari, Mikhael Gromov (mathematician), and Shing-Tung Yau. – Jonesey95 (talk) 15:57, 29 October 2021 (UTC)Reply

What do you suggest be used in substitution for {wikicite}? Or can {wikicite} be modified not to interact badly with such reference text? EEng 16:20, 29 October 2021 (UTC)Reply
I haven't explored to see why it is used here, but what I think would be better is something that generates the necessary functionality without using cite tags in this syntactically questionable and invalid manner. What is the functionality that is needed here? This is all that Wikicite does:
<cite class="citation wikicite" id={{{ref|"Reference-{{{id}}}"}}}>{{{reference}}}</cite>
And this is all that Rma does, aside from some presentation:
{{wikicite | ref= {{{tag|{{{1}}}}}} | reference= {{{reference|{{{2}}}}}}}}
So that simplifies Rma to this (if I am reading correctly) plus some presentation:
<cite class="citation wikicite" id={{{tag|{{{1}}}}}}>{{{reference|{{{2}}}}}}</cite>
Do we need cite tags, or can we use div tags instead? I will experiment in the sandbox if the answer is not known here. If we don't need to modify wikicite, that would probably be best, since it has 20 times the transclusions of this template. – Jonesey95 (talk) 16:36, 29 October 2021 (UTC)Reply
I created {rma} back in the day, and I'm pretty sure I modeled it on something else; it's pretty clear that its key function is to supply the tag. As for not modifying {wikicite}, I'm not sure I follow your logic. If we can fix this specific problem by removing a general restriction on {wikicite}, then that would be best, especially because {wikicite}'s so widely used. EEng 16:48, 29 October 2021 (UTC)Reply

Superscript callout links do not work on mobile edit

The superscript "callout" links generated by {{ran}} don't work on the Minerva theme. All users on mobile devices like cellphones or tablets will by default get the Minerva theme and these nonfunctional links. On Minerva, the superscript link is visible and the link to the anchor can actually be copied or opened in another tab, but something in Minerva prevents anything from happening on a normal tap. This seems to have something to do with how Minerva redirects reference links to instead launch a small popup for mobile.

Here are a couple links to past threads that I've attempted to start about it:

Also, {{Citeref}} does work on Minerva, perhaps because it ignores the standard references? I hope matthiaspaul does not mind being pinged for their expertise.

Regards, Rjjiii (talk) 03:04, 1 May 2023 (UTC)Reply

I have set up this template's testcases page with an example that shows the functions (pop-up and jumping to the reference upon clicking) working properly in all of the skins except for Minerva. I do not know of any syntax errors that exist within that page or within the two relevant templates that are used. I think at this point you should file a Phabricator bug against the Minerva skin. – Jonesey95 (talk) 04:55, 1 May 2023 (UTC)Reply
Thanks, I'll make an account over there, post the bug report, and put a link here afterwards. Rjjiii (talk) 07:45, 1 May 2023 (UTC)Reply
Yep, that's what I would suggest as well. --Matthiaspaul (talk) 08:33, 1 May 2023 (UTC)Reply
https://phabricator.wikimedia.org/T335726
I appreciate the guidance, Rjjiii (talk) 06:10, 2 May 2023 (UTC)Reply

This is probably because Minerva shows references as popups instead of navigating to the reference's section. The <sup class="reference"> makes Minerva think this should happen here too, but it doesn't. Does this template need to use the reference class? I can't see any specific styling attached to that class in neither Minerva nor Vector, so I think it's unnecessary. When I remove that class (even just with the browser inspector), the link starts working.

^Per jhsoby, Rjjiii (talk) 07:20, 2 May 2023 (UTC)Reply
I updated the sandbox and test cases. This works on my phone. Does it work for you all? Edit: that breaks tooltips on desktop. Rjjiii (talk) 07:31, 2 May 2023 (UTC)Reply
Okay, check the sandbox.
  • Removing the reference class caused the link to work on mobile.
  • Prefixing "CITEREF" in the anchor link caused the popup to launch on desktop.
Let me know if that works, Rjjiii (talk) 08:29, 2 May 2023 (UTC)Reply
Matthiaspaul and Jonesey95, I synced the sandbox templates and updated them. They seem to work fine on all browsers and themes, but this changes the anchors. Some articles using the template only (like Harry R. Lewis) would be unaffected, but a few articles that use the rma links manually (like Phineas Gage) would need all manual links updated. Rjjiii (talk) 03:46, 3 May 2023 (UTC)Reply
The above problem actually doesn't seem like too much of an issue now that I'm thinking about it. After checking it looks like almost no articles use the manual links. And changing the manual links gives them the nice popup effect on desktop anyway. Here's a demo: User:Rjjiii/rma sandbox, and here's the mobile skin: https://en.wikipedia.org/wiki/User:Rjjiii/rma_sandbox?useskin=Minerva I think this is a solution, Rjjiii (talk) 05:03, 3 May 2023 (UTC)Reply