Topic on Project:Support desk

<a> tags aren't parsed correctly

13
Summary by Kghbln

Continues in this thread

182.232.61.94 (talkcontribs)

I have a MediaWiki 1.34.0 Hebrew website with only one extension (ContactPage) and I prefer not to install any further extensions.

I understand that a proper references/footnotes mechanism for Hebrew MediaWiki websites, requires installing extra modules beyond the core Cite as well as working with very complex Wiki syntax templates which is something I want to avoid; therefore, I desire to use the following templates and JavaScript as a frontend alternative:

footnotes_list

<includeonly><ol class="footnotes_list"></ol></includeonly><noinclude>

[[קטגוריה:תבניות]]
</noinclude>

footnote

<includeonly><span dir="rtl" class="footnote"><sup class="footnote_inner">{{{1}}}</sup></span></includeonly><noinclude>

[[קטגוריה:תבניות]]
</noinclude>

JavaScript (non Babelified)

document.querySelectorAll(".footnote>sup").forEach((element, i) => {
    const li = document.createElement("li");
    li.append(...element.childNodes);
    element.textContent = i + 1;
    const footnotes_list = document.querySelector(".footnotes_list"); 
    footnotes_list.appendChild(li); 
});

const numbers = Array.from(Array(100)).map((e,i)=>i+1)
document.querySelectorAll(".footnote").forEach( (element, i)=>{
    element.setAttribute("href", `#footnote_${numbers[i]}`)
    element.setAttribute("id", "fn_"+numbers[i]);
});
document.querySelectorAll(".footnotes_list>li").forEach( (element, i)=>{
    element.setAttribute("id", "footnote_"+numbers[i]);
    element.setAttribute("href", `#fn_${numbers[i]}`)
});

My problem

<a> tags aren't parsed correctly → I get the output instead a footnote number, anywhere:

<a dir="rtl" class="footnote">או מבוססת מערכת הפעלה עם ליבות אחרות</a>

My question

What might cause <a> tags not to be parsed correctly?

182.232.61.94 (talkcontribs)
Bawolff (talkcontribs)

mediawiki doesnt support a tags. Ise normal wiki link syntax ([https://example.com text of link here]). If you need to set attributes, wrap in a span.

I would reccomend just using the cite extension. The templates hewiki uses are complex, but cite by itself is not and there is no requirement to use those templates if you dont want to.

49.230.94.95 (talkcontribs)

@Bawolff

if I use <span></span> instead <a></a> then the entire footnote_number structure becomes unclickable.

If I use <span>a></a></span> then I do get numbers wrapped in literal <a></a> and of course unclickable.

If think that at least there should be some LocalSettings.php command to allow regular usage of <a> tags.

Kindly,


Bawolff (talkcontribs)

use [https://example.com <span class="foo">text here</span>]

To make

text here


You can use the special class plainlinks to get rid of external link icons example

49.230.94.95 (talkcontribs)

@Bawolff

Neither:

<includeonly>[<span dir="rtl" class="footnote"><sup class="footnote_inner">{{{1}}}</sup></span>]</includeonly><noinclude>

[[קטגוריה:תבניות]]
</noinclude>

Nor:

<includeonly><span dir="rtl" class="footnote">[<sup class="footnote_inner">{{{1}}}</sup>]</span></includeonly><noinclude>

[[קטגוריה:תבניות]]
</noinclude>

Worked for me properly.

No link was created, rather just plain brackets.

Bawolff (talkcontribs)

try

<includeonly><span dir="rtl" class="footnote">[{{{1}}} <sup class="footnote_inner">{{{1}}}</sup>]</span></includeonly><noinclude>

[[קטגוריה:תבניות]]
</noinclude>

Assuming that param 1 is a full url (starting with https:// )

49.230.94.95 (talkcontribs)

@Bawolff

Thank you dearly, but it isn't a full URL, rather a local link.

As I am not a frontend expert and pretty much ran out of time for experimenting JS with this (and also get annoyed to Babelifi JS and past it in the JS webpage inside my Wiki which lacks any syntax highlighting when edited), I think it is best for me to study the source code of the common (Cite-Scribunto based) templates and create these backend.

49.230.94.95 (talkcontribs)

(and also get annoyed to Babelifi JS and past it in the JS webpage inside my Wiki which lacks any syntax highlighting when edited each time anew)*

Bawolff (talkcontribs)

for syntax highlighting there is extension:CodeEditor.

the local link version basically uses [[{{{1}}}|<span class="foo">{{{1}}}</span>]] syntax instead.

49.230.94.95 (talkcontribs)

Well, with that code neither footnotes, nor footnote numbers get created:

<includeonly>[[{{{1}}}|<span dir="rtl" class="footnote">{{{1}}}</span>]]</includeonly><noinclude>

[[קטגוריה:תבניות]]
</noinclude>

Just saying.

49.230.94.95 (talkcontribs)
Kghbln (talkcontribs)