14

If we copy text from a Wikipedia page, this is roughly what we get:

Sentence spacing is the horizontal space between sentences in typeset text. It is a matter of typographical convention.[1] Since the introduction of movable-type printing in Europe, various sentence spacing conventions have been used in languages with a Latin-derived alphabet.[2] These include a normal word space (as between the words in a sentence), a single enlarged space, two full spaces, and, most recently in digital media, no space.[3] Although modern digital fonts can automatically adjust a single word space to create visually pleasing and consistent spacing following terminal punctuation,[4] most debate is about whether to strike a keyboard's spacebar once or twice between sentences.[5]

I do not wish to copy the parts [1] and [2] etc. This is actually what I wanted to copy:

Sentence spacing is the horizontal space between sentences in typeset text. It is a matter of typographical convention. Since the introduction of movable-type printing in Europe, various sentence spacing conventions have been used in languages with a Latin-derived alphabet. These include a normal word space (as between the words in a sentence), a single enlarged space, two full spaces, and, most recently in digital media, no space. Although modern digital fonts can automatically adjust a single word space to create visually pleasing and consistent spacing following terminal punctuation, most debate is about whether to strike a keyboard's spacebar once or twice between sentences.

The selected answer below uses regex but it doesn't work everytime. (If the actual text itself contains [ and ] the regex shouldn't be removing them.)

Are there better solutions?

Pacerier
  • 27,223
  • Those are references which probably are important because they often support the credibility of the information being presented. Including references is helpful, particularly to researchers. – Randolf Richardson Aug 17 '11 at 06:19
  • @Randolf Including references can be helpful, especially for researchers. not for normal-beings who just want the information – Pacerier Aug 17 '11 at 06:20
  • Your word processor's search and replace feature, possibly called from a macro, could come in handy here. – Keith Aug 17 '11 at 06:34
  • I did upvote your question, by the way, because I do think it's a good one. Regarding references, many people expect to see them, especially professors in university (if you're planning to attend one, you'll almost certainly find that most professors will expect references be included in any research papers you write, and you'll probably hear other students talking about references from time-to-time). – Randolf Richardson Aug 17 '11 at 06:43
  • @Randolf i mean i just want to store the information for personal future reading and use. – Pacerier Aug 17 '11 at 12:22
  • Despite Wikipedia, one unexpectedly still has to work to create reports for school. ;) – Daniel Beck Aug 28 '11 at 17:30

2 Answers2

14

A bookmarklet is your friend...

Create a new browser bookmark and copy the javascript code below into it - when you want to copy some text from wikipedia, just click it beforehand and it'll remove all instances of [n] to meet your requirement in the question.

javascript:function a (){document.body.innerHTML=document.body.innerHTML.replace(/<sup\b[^>]*>(.*?)<\/sup>/gi, "" );return;}; a();

Behind the scenes, it's just doing a regular expression search and replace of all <sup>...</sup> HTML tags on the page.

I've just tried this in IE7 and it works fine, so hopefully should be ok in other browsers too.

I'll credit this SO thread with pointing me in the right direction - I knew a bookmarklet was the way to go, but had never written one before.

  • 1
    +1, this is the only way I can think of doing this. Even additional browser extensions would have to use some kind of Javascript analysis to do this (and indeed most do). – Breakthrough Aug 31 '11 at 15:20
  • 1
    In the decade since this answer, a new js node selector api has been introduced and implemented in all browsers, so you can use this simpler snippet: javascript:document.querySelectorAll('.reference').forEach(r => r.remove()) – Håken Lid May 16 '21 at 15:09
1

CSS property user-select specifies whether the element's text is selectable (with CtrlA, mouse highlight, etc). The following CSS rule for Wikipedia will omit the inline references from selection when highlighting the article's text:

sup.reference { user-select: none; }

Add it to your Wikipedia CSS file (which has effect only while you are logged in); or to a user stylesheet through a browser extension (e.g. Stylus), or through browser's internal capabilites (e.g. userContent.css for Firefox, custom.css for Chromium), which will be active regardless of being logged into the Wikipedia account.

See https://en.wikipedia.org/wiki/Help:Reference_display_customization for more examples. For instance, to not show the inline citation numbers at all, use:

sup.reference { display: none; }
exquo
  • 21