通过语法突出显示将 diff 输出粘贴到 Microsoft Outlook 中

发布于 2024-07-18 11:15:48 字数 384 浏览 4 评论 0原文

如何将 diff 输出 (diff old-version.cpp new-version.cpp) 复制到 Outlook 电子邮件中,以便我可以使用语法突出显示将其发送给其他人?

我要么想将差异输出传输到一个程序,该程序将其格式化复制到剪贴板(p4 diff file.cpp | rtfpatch),或者有一个 Outlook 插件让我选择一些文本,单击一个按钮,它就会变色。

我使用 Windows(XP 和 Vista)、Perforce、Visual Studio、Beyond Compare 3、Outlook 2007。任何使用这些工具组合的东西都会很好用(我不打算改变我的主要 diff 程序,等等...)。

How can I copy diff output (diff old-version.cpp new-version.cpp) into an Outlook email so I can send it to other people with syntax highlighting?

I'd either like to pipe diff output to a program that will copy it to the clipboard with formatting (p4 diff file.cpp | rtfpatch) or have a plugin for Outlook that lets me select some text, click a button, and it gets colorized.

I use Windows (XP and Vista), Perforce, Visual Studio, Beyond Compare 3, Outlook 2007. Anything using a combination of those tools would work great (I'm not looking to change my main diff program, etc...).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

沦落红尘 2024-07-25 11:15:48

您可以使用“会话”菜单中的 Beyond Compare 的“文本比较报告”命令来执行此操作。 使用“交错”布局样式、“HTML 报告”输出样式和“复制到剪贴板”命令,它会将其作为彩色 HTML 复制到剪贴板。 我没有 Outlook 来测试,但将其粘贴到 Word 中确实有效。

You can use Beyond Compare's "Text Compare Report" command in the Session menu to do this. Use the "Interleaved" layout style, the "HTML Report" output style and the "Copy to Clipboard" command and it will copy it to the clipboard as colored HTML. I don't have Outlook to test with, but it certainly works pasting it into Word.

伪装你 2024-07-25 11:15:48

我发现的另一个不错的解决方案是 vim 插件。 cliphtml.vim 为您提供 < code>:ClipHtml ex 命令将整个文件或选定区域复制到剪贴板,并带有 vim 的突出显示。

需要Python。

Another decent solution I've found is a vim plugin. cliphtml.vim gives you the :ClipHtml ex command that will copy the whole file or the selected region to the clipboard with vim's highlighting.

Requires python.

笑,眼淚并存 2024-07-25 11:15:48

许多编辑器都能够将语法突出显示的文件导出为 HTML。 从那里,您可以将 HTML 粘贴到 Outlook 中。 例如,要将文件导出为 Vim 中的 HTML,请使用 :TOhtml

此 Visual Studio 插件 还提供“导出为 HTML”功能。 值得一试。

Many editors have the ability to export syntax-highlighted files as HTML. From there, you can paste the HTML into Outlook. For example, to export a file to HTML in Vim, use :TOhtml.

This Visual Studio addon offers the "export to HTML" functionality as well. It's worth giving it a try.

烟火散人牵绊 2024-07-25 11:15:48

要将 html 粘贴到 Outlook 中,您应该尝试将其粘贴到消息源中。
右键单击 HTML 消息的正文并选择“查看源代码”,然后将您的 html 粘贴到其中。

另一种方法是使用批处理文件编写脚本,并将消息 html 正文设置为等于您的 html 文本并发送。 stackoverflow 上有很多通过脚本发送电子邮件的示例。 有多种方法可以做到这一点,具体取决于您安装的内容等。一个例子是

从 Windows 脚本发送邮件

使用 CDO

To paste the html into into outlook you should try an past it into th source of the msg.
Right click the body of the HTML message and the select View source, then past your html into that.

The other way would be to script it in a batch file using and set the Message html body to equal your html text and send. There are quite a few examples of sending email via script on stackoverflow. There are a number of ways to do it depending what you have installed etc. one example is

Send mail from a Windows script

using CDO

自演自醉 2024-07-25 11:15:48

我想出了一个解决方案,使用 p4diff.exe 程序制作一个批处理文件,以将文件与 Perforce 进行比较。

它的问题是 p4diff 输出整个文件,而不仅仅是更改的部分(我也更喜欢统一差异)。 此外,比较特定修订版本需要从命令行调用 rtfdiff(自定义工具仅针对 HEAD 进行比较)。

p4v 自定义工具 定义(将其写入tool.xml,然后将其导入到 p4v 的“管理自定义工具”菜单中):

<CustomToolDef>
  <Definition>
    <Name>RTF Diff</Name>
    <Command>c:\scripts\rtfdiff.bat</Command>
    <Arguments>%f</Arguments>
  </Definition>
  <AddToContext>true</AddToContext>
</CustomToolDef>

其中 rtfdiff.bat 是

:: Use p4diff to get copy-pasteable diff output.

:: setlocal so we use the default after script terminates
setlocal
set P4DIFF=c:\Perforce\p4diff.exe
:: Diff all inputs to allow multiple revisions (must be in increasing order)
p4 diff %*

这将允许您右键单击文件并选择“RTF Diff”或通过命令行调用 rtfdiff.bat (rtfdiff.bat文件.txt#1 文件.txt#2)。

I figured out a solution to make a batch file that diffs files from Perforce using the p4diff.exe program.

The problem with it is p4diff outputs the whole file, not only the changed sections (I'd also prefer unified diff). Also, diffing specific revisions requires calling rtfdiff from command line (the custom tool just diffs against HEAD).

p4v custom tool definition (write this to tool.xml and then import it in p4v's Manage Custom Tools menu):

<CustomToolDef>
  <Definition>
    <Name>RTF Diff</Name>
    <Command>c:\scripts\rtfdiff.bat</Command>
    <Arguments>%f</Arguments>
  </Definition>
  <AddToContext>true</AddToContext>
</CustomToolDef>

where rtfdiff.bat is

:: Use p4diff to get copy-pasteable diff output.

:: setlocal so we use the default after script terminates
setlocal
set P4DIFF=c:\Perforce\p4diff.exe
:: Diff all inputs to allow multiple revisions (must be in increasing order)
p4 diff %*

That will let you right click on a file and select "RTF Diff" or call rtfdiff.bat via command line (rtfdiff.bat file.txt#1 file.txt#2).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文