Como podemos copiar texto da Wikipedia sem as partes de citação “[1]”, “[2]”, “[3]”?

4

Se copiarmos o texto da página da Wikipédia , é mais ou menos isso nós temos:

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]

Eu não desejo copiar as partes [1] e [2] etc. Isso é exatamente o que eu queria copiar:

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.

A resposta selecionada abaixo usa regex, mas não funciona sempre . (Se o texto em si contiver [ e ] , o regex não deve removê-los.)

Existem soluções melhores?

    
por Pacerier 17.08.2011 / 08:10

1 resposta

4

Um bookmarklet é seu amigo ...

Crie um novo marcador de navegador e copie o código javascript abaixo nele - quando você quiser copiar algum texto da wikipedia, basta clicar nele antes e remover todas as instâncias de [n] para cumpra sua exigência na pergunta.

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

Por trás das cenas, é apenas fazer uma pesquisa de expressão regular e substituir todas as tags HTML <sup>...</sup> na página.

Eu apenas tentei isso no IE7 e ele funciona bem, então espero que esteja ok em outros navegadores também.

Eu credito este thread SO com me apontando na direção certa - eu sabia que um bookmarklet era o caminho a percorrer, mas nunca tinha escrito um antes.

    
por 31.08.2011 / 17:14