User talk:Enterprisey/copy-section-link

Escaping brackets in section headings

edit

User:Enterprisey/copy-section-link doesn't escape some characters that are needed for wikilinks to work as intended. For example, the script produces the first example below, when I expected it to produce the second URL-encoded version. Producing code using Template:slink would be an alternate option.

Markup Renders as
[[Talk:Peer review/Archive 2#{mergeX} 'Open peer review' and 'Anonymous peer review']]

[[Talk:Peer review/Archive 2#{mergeX} 'Open peer review' and 'Anonymous peer review']]

[[Talk:Peer review/Archive 2#%7BmergeX%7D 'Open peer review' and 'Anonymous peer review']]
{{slink|Talk:Peer review/Archive 2#{mergeX} 'Open peer review' and 'Anonymous peer review'}}

Daask (talk) 20:58, 25 November 2024 (UTC)Reply

Daask, thank you for your bug report. I've incorporated a fix for this issue into User:Andrybak/Scripts/copy-section-link.js. —⁠andrybak (talk) 21:48, 25 November 2024 (UTC)Reply
@Andrybak. Hey there. I've got a list of bugs and suggestions I've been keeping at https://github.com/NovemLinguae/UserScripts/issues/130 if you want to take a look. Maybe some of them will be a good fit for your fork. –Novem Linguae (talk) 01:19, 26 November 2024 (UTC)Reply
Oh, according to my notes, brackets also need escaping, not just braces. And probably a bunch of other special URL characters too. Have you considered using JavaScript's encodeURI() or encodeURIComponent() functions to capture a wider swath of these special characters? One of those might work better than replace(). –Novem Linguae (talk) 01:22, 26 November 2024 (UTC)Reply
edit

The popup that this script produces to display the section link is obscured behind wikitable headings, as can be seen at List of football clubs in India#Andhra Pradesh. The problem appears in all skins and with both User:Enterprisey/copy-section-link.js and User:Andrybak/Scripts/copy-section-link.js. Daask (talk) 09:19, 27 November 2024 (UTC)Reply