Colar texto rico com formatação

2

Gostaria de poder colar rich text que copiei (por exemplo) de uma página da Web diretamente no bloco de notas (ou outra caixa de texto simples) e retenha detalhes como URLs etc.

Por exemplo, se eu copiei o texto de uma página da Web que lê " Stackexchange " (observe como ele tem um link clicável para " link "), colando no Wordpad ou em algum programa do Office, colará como texto clicável. Seria ótimo poder colar diretamente no bloco de notas como

http://stackexchange.com Stackexchange

ou

<a href="http://stackexchange.com">Stackexchange</a>

ou similar.

Eu pensei que um gerenciador de clipboard deveria ser capaz de fazer isso, então eu tentei CLC e ArsClip. No CLC, eu poderia pelo menos ver o HTML bruto, mas não há maneira óbvia de colocar isso na prancheta. Eu poderia salvá-lo em um arquivo, mas isso não é prático.

    
por aland 24.03.2013 / 17:46

3 respostas

3

Tente usar "Colar especial"

O Notepad ++ tem uma opção, [Editar, Colar Especial, Colar Conteúdo HTML]. Copiar de vários navegadores dá resultados diferentes. Copiei a mesma seção da sua pergunta em cada navegador e a colei no Notepad ++.

Do Firefox:

Version:0.9
StartHTML:00000177
EndHTML:00000550
StartFragment:00000211
EndFragment:00000514
SourceURL:http://superuser.com/questions/570820/paste-rich-text-with-formating
<html><body>
<!--StartFragment-->For example, if I copied text from a webpage that read "Stackexchange" and was a clickable link to "<a href="http://stackexchange.com">http://stackexchange.com</a>",
 pasting to wordpad or some office program, will paste as clickable 
text. It would be great to be able to paste directly in notepad as<!--EndFragment-->
</body>
</html>

Do Chrome:

Version:0.9
StartHTML:0000000185
EndHTML:0000002191
StartFragment:0000000221
EndFragment:0000002155
SourceURL:http://superuser.com/questions/570820/paste-rich-text-with-formating
<html>
<body>
<!--StartFragment--><span style="color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none;">For example, if I copied text from a webpage that read "Stackexchange" and was a clickable link to "</span><a href="http://stackexchange.com/" style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(19, 179, 189); text-decoration: none; cursor: pointer; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">http://stackexchange.com</a><span style="color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none;">", pasting to wordpad or some office program, will paste as clickable text. It would be great to be able to paste directly in notepad as</span><!--EndFragment-->
</body>
</html>

Do IE:

Version:1.0
StartHTML:000000231
EndHTML:000005122
StartFragment:000004682
EndFragment:000004996
StartSelection:000004682
EndSelection:000004996
SourceURL:http://superuser.com/questions/570820/paste-rich-text-with-formating
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>windows 7 - Paste rich text with formating - Super User</TITLE><LINK 
rel="shortcut icon" 
href="http://cdn.sstatic.net/superuser/img/favicon.ico"><LINK 
rel="apple-touch-icon image_src" 
href="http://cdn.sstatic.net/superuser/img/apple-touch-icon.png"><LINK 
title="Super User" rel=search type=application/opensearchdescription+xml 
href="/opensearch.xml">
<SCRIPT type=text/javascript 
src="http://engine.adzerk.net/z/8476/adzerk1_2_4_46,adzerk2_2_17_47?keywords=windows-7,clipboard"async="true"></SCRIPT>

<SCRIPT type=text/javascript src="http://www.google-analytics.com/ga.js"async="true"></SCRIPT>

<SCRIPT type=text/javascript src="http://edge.quantserve.com/quant.js"async="true"></SCRIPT>

<SCRIPT type=text/javascript 
src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></SCRIPT>

<SCRIPT type=text/javascript 
src="http://cdn.sstatic.net/js/stub.js?v=1f945f8e69cb"></SCRIPT><LINKrel=stylesheettype=text/csshref="http://cdn.sstatic.net/superuser/all.css?v=8eaaa600ccef"><LINK 
rel=canonical 
href="http://superuser.com/questions/570820/paste-rich-text-with-formating"><LINK 
title="Feed for question 'Paste rich text with formating'" rel=alternate 
type=application/atom+xml href="/feeds/question/570820">
<SCRIPT type=text/javascript>

        StackExchange.ready(function () {
            StackExchange.using("postValidation", function () {
                StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
            });


            StackExchange.question.init({hasOpenBounty:true,showAnswerHelp:true,totalCommentCount:4,shownCommentCount:4,highlightColor:'#BEB013',backgroundColor:'#FFF',questionId:570820});

            styleCode();

                StackExchange.realtime.subscribeToQuestion('3', '570820');


        });
    </SCRIPT>

<SCRIPT type=text/javascript>
        StackExchange.ready(function () {
            StackExchange.realtime.init('ws://sockets.ny.stackexchange.com:80');
            StackExchange.realtime.subscribeToInboxNotifications();
                    StackExchange.realtime.subscribeToReputationNotifications('3');
                });
    </SCRIPT>

<SCRIPT type=text/javascript>
        StackExchange.init({"stackAuthUrl":"https://stackauth.com","serverTime":1366208314,"enableUserHovercards":true,"site":{"name":"Super User","description":"Q&A for computer enthusiasts and power users","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LcDNwYAAAAAAG_X1rC8kTtLBP6XS2Ym1N0n9kSY","useNewStyleFavoriteTagsEditor":true,"enableSocialMediaInSharePopup":true},"user":{"fkey":"edbc1fe628205ffa4db5a492350fc54b","isAnonymous":true}});
        StackExchange.using.setCacheBreakers({"js/prettify-full.js":"6c261bebf56a","js/moderator.js":"f96f7e4ee5dc","js/full-anon.js":"4aa778f20142","js/full.js":"2cb347042411","js/wmd.js":"605c62dd1a01","js/third-party/jquery.autocomplete.min.js":"e5f01e97f7c3","js/mobile.js":"6eb68240242f","js/help.js":"fc9fb0517db2","js/tageditor.js":"450c9e8426fc","js/tageditornew.js":"b6c68ad4c7dd","js/inline-tag-editing.js":"8e84e8a137f7","js/revisions.js":"7273bb714bba","js/review.js":"5b2105439221","js/tagsuggestions.js":"aa48ef6154df","js/post-validation.js":"98fa812e7e1a","js/explore-qlist.js":"6c836f42bd92"});

    </SCRIPT>

<SCRIPT type=text/javascript>
        StackExchange.using("gps", function() {
             StackExchange.gps.init(true);
        });
    </SCRIPT>

<SCRIPT type=text/javascript 
src="http://cdn.sstatic.net/js/full-anon.js?v=4aa778f20142"async="async"></SCRIPT>

<SCRIPT type=text/javascript 
src="http://cdn.sstatic.net/js/post-validation.js?v=98fa812e7e1a"async="async"></SCRIPT>

<SCRIPT type=text/javascript 
src="http://static.adzerk.net/Extensions/adFeedback.js"></SCRIPT><LINKrel=stylesheethref="http://static.adzerk.net/Extensions/adFeedback.css"></HEAD>

<BODY class=question-page jQuery17103772600276367371="4">

<DIV class=container>

<DIV id=content>

<DIV itemtype="http://schema.org/Article" itemscope>

<DIV id=mainbar>

<DIV id=question class=question jQuery17103772600276367371="12" 
data-questionid="570820">

<TABLE>

<TBODY>

<TR>

<TD class=postcell>

<DIV>

<DIV class=post-text itemprop="description"><!--StartFragment--><P>For example, if I copied text from a webpage that read "Stackexchange" and 
was a clickable link to "<A 
href="http://stackexchange.com">http://stackexchange.com</A>", pasting to 
wordpad or some office program, will paste as clickable text. It would be great 
to be able to paste directly in notepad as</P><!--EndFragment--></DIV>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
</DIV>
</DIV>
</DIV>
</DIV>
</BODY>
</HTML>
    
por 17.04.2013 / 16:23
0

Para o seu exemplo sobre páginas da web, você pode usar o Chrome e as ferramentas do desenvolvedor:

CMD + Opção + c para inspecionar a parte que você deseja copiar e, em seguida, no Elements explorer, clique com o botão direito no nó quer e escolha Copiar como HTML.

    
por 15.04.2013 / 16:59
0

Para o Chrome:

A maneira mais fácil é clicar com o botão direito do mouse no hiperlink. No menu de contexto, selecione a opção Inspect Element , em seguida, pressione Ctrl + c para copiar o link junto com a formatação HTML.

Alternativamente:

Eu criei um script AutoHotkey para automatizar todo o processo com apenas uma tecla de atalho ( Ctrl + m ):

^m::
MouseClick, right
Sleep, 1000
Send, {DOWN  6}{ENTER}
Sleep, 1000
Send, {CTRLDOWN}c{CTRLUP}

Com o script acima, colocando o mouse no hyperlink e pressionando Ctrl + m copiará o link formatado para a área de transferência.

Para o Firefox:

  • Mantenha o mouse no link e, em seguida, clique com o botão direito do mouse.
  • Pressione Q (ou selecione Inspecionar Elemento).
  • Selecione Copy Outer HTML no menu suspenso. Seu link será copiado junto com a formatação HTML.

    
por 21.04.2013 / 08:35