我希望能够将从网页复制的富文本直接粘贴到记事本(或其他纯文本框)中并保留 URL 等详细信息。
例如,如果我从网页上复制了以下文字“Stackchange“(请注意它有一个可点击的链接”http://stackexchange.com”),粘贴到写字板或某些办公程序中,将粘贴为可点击的文本。如果能够直接在记事本中粘贴,那就太好了
http://stackexchange.com Stackexchange
或者
<a href="http://stackexchange.com">Stackexchange</a>
或类似的东西。
我认为剪贴板管理器应该能够做到这一点,所以我尝试了 CLC 和 ArsClip。在 CLC 中,我至少可以看到原始 html,但没有明显的方法将其放到剪贴板上。我可以将其保存到文件中,但这不切实际。
答案1
尝试使用“选择性粘贴”
Notepad++ 有一个选项,[编辑,选择性粘贴,粘贴 HTML 内容]。从不同的浏览器复制会产生不同的结果。我在每个浏览器中复制了您问题中的相同部分,并将其粘贴到 Notepad++ 中。
通过 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>
从 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>
从 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>
<LINK rel=stylesheet type=text/css
href="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>
<LINK rel=stylesheet
href="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>
答案2
对于有关网页的示例,您可以使用 Chrome 和开发人员工具:
CMD++ 检查要复制的部分,然后在元素资源管理器中右键单击所需节点并选择“复制为 HTML” Option。c
答案3
对于 Chrome:
最简单的方法是右键单击超链接。从上下文菜单中选择选项,Inspect Element
然后按Ctrl+c复制链接以及 HTML 格式。
或者:
我已经创建了一个自动热键只需一个热键(Ctrl+ m)即可自动执行整个过程的脚本:
^m::
MouseClick, right
Sleep, 1000
Send, {DOWN 6}{ENTER}
Sleep, 1000
Send, {CTRLDOWN}c{CTRLUP}
使用上述脚本将鼠标放在超链接上并按Ctrl+m将格式化的链接复制到剪贴板。
对于 Firefox:
- 将鼠标放在链接上,然后单击鼠标右键。
- 按 Q(或选择检查元素)。
- 从下拉菜单中选择
Copy Outer HTML
。您的链接将与 HTML 格式一起复制。