Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying links with explicit underscore or lowercase title #231

Open
lahwaacz opened this issue Dec 19, 2018 · 1 comment
Open

Copying links with explicit underscore or lowercase title #231

lahwaacz opened this issue Dec 19, 2018 · 1 comment

Comments

@lahwaacz
Copy link
Contributor

It would be nice if the "copy link" feature from v5.0.0 preserved explicit underscores in titles and sections and lowercase titles. See e.g. systemd, mod_python, VMware#Package build for x86_64.

@kynikos kynikos added this to the 5.1.0 milestone Dec 22, 2018
@kynikos
Copy link
Owner

kynikos commented Dec 22, 2018

I came here and said oh this is going to be easy!, then 5 seconds later I remebered the whole escaping mess...

(What follows is mostly a note to myself; tl;dr we'll have to stick to manual link fixing for a while longer... ^^)

Currently the "copy link" feature uses the "id" attribute of the heading's span.mw-headline element, which uses underscores only, which I naively replace with spaces. To partly fix this problem I could use the rendered section heading directly, but for example I use automatic heading numbers, which are spans that are unfortunately simply prepended to the rendered heading title thus making it quite a messy job to isolate the wanted content safely...

It's very interesting (for me) to note that headings with breaking characters are given an additional span element with a dot-encoded id attribute! It will be useful...

About title casing, currently I'm using the (hopefully safe enough) Javascript API, which doesn't seem to care about lcfirst though, so to respect capitalization I should resort to using the rendered page title, but that feels messy (see above) and without proper tests I don't know what that would break.

I should really approach this whole problem scientifically and properly find out what breaks when, with properly designed tests, and find the best way to address each case, i.e. where to read the title to put in the link, how to further encode or decode it, and whether to use a label (and maybe add another command to copy a link with or without a label, i.e. pretty-and-long or ugly-and-short). I've looked for some function already on the market but couldn't find anything

As a temporary fix I could add a command for each of the possible ways to read titles and section headings and compose links with them, and then let the user decide which one to use, but it would become more confusing to use than it is now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants