ENH,UBY: strip https, en.wikipedia.org w/ JS #21
Copy link
Copy link
Open
Description
links = $('a.reference.external');
function striphttps(a, link) {
if (link.text.startsWith('https://')) {
link.text = link.text.substring(8); }
}
links.map(striphttps);
function stripenwikipedia(a, link) {
if (link.text.startsWith('en.wikipedia.org/wiki/')) {
if (link.previousSibling !== null && link.previousSibling.textContent.startsWith('Wikipedia:')) {
link.text = link.text.substring(22);
} else {
link.text = "wikipedia: " + link.text.substring(22);
}
}
}
links.map(stripenwikipedia);[EDIT]
The code for this lives in westurner/sphinx_wrd_theme:
https://github.com/westurner/wrd_sphinx_theme/blob/master/wrd_sphinx_theme/template/static/js/linkstyles.js
Reactions are currently unavailable
Activity
westurner commentedon Mar 3, 2019
This should be optional so that copy/paste to non-HTML formats doesn't break links (and strip the helpful https:// part)
One approach would be to store the original link text as an extra attribute and revert when the toggle checkbox is clicked.
westurner commentedon Mar 3, 2019
This could be very helpful on mobile devices.
westurner commentedon Mar 3, 2019
Additional patterns: