I'm writing some documentation that will occasionally include C# or C++ code snippets.
我正在编写一些偶尔会包含C#或C ++代码片段的文档。
In Visual Studio, the Edit/Copy command includes syntax coloring. You can see this if you paste the text into, e.g., Word or Outlook. In fact, if you use the "Paste Special..." command, you can see that it's "Rich Text (RTF)".
在Visual Studio中,“编辑/复制”命令包括语法着色。如果将文本粘贴到例如Word或Outlook中,则可以看到此内容。实际上,如果使用“选择性粘贴...”命令,则可以看到它是“富文本(RTF)”。
However, when pasting this text into an HTML file in Visual Studio, none of the colouring (or even formatting) is preserved.
但是,将此文本粘贴到Visual Studio中的HTML文件时,不会保留任何着色(甚至格式化)。
Any ideas? I'm looking specifically for something that works locally (preferably in Visual Studio), not JavaScript-based solutions (such as SyntaxHighlighter).
有任何想法吗?我正在寻找适合本地工作的东西(最好是在Visual Studio中),而不是基于JavaScript的解决方案(例如SyntaxHighlighter)。
3 个解决方案
#1
There's an addin called CopySourceAsHtml which does a pretty neat job. I've used it a few times, but I use a Javascript to do the highlighting on my blog these days (so it's "plaintext readable").
有一个名为CopySourceAsHtml的插件,它做了一个相当干净的工作。我已经使用了几次,但是这些天我使用Javascript在我的博客上进行突出显示(因此它是“明文可读的”)。
#2
You can use existing C to HTML syntax highlighter tools for converting your snippets into HTML and copy&pasting from there. Here's a list of such tools (not exhaustive and in no particular order):
您可以使用现有的C到HTML语法高亮显示工具将您的代码段转换为HTML并从那里复制和粘贴。这是一个这样的工具列表(不详尽,没有特别的顺序):
- GNU Enscript
- GNU Emacs with htmlize.el module allows you to dump a highlighted Emacs buffer as HTML
带有htmlize.el模块的GNU Emacs允许您将突出显示的Emacs缓冲区转储为HTML
There might also exist web services that allow you to copy&paste C code into a form and get highlighted HTML back.
可能还存在Web服务,允许您将C代码复制并粘贴到表单中并重新突出显示HTML。
#3
I use this for highlighting code on webpages. It's simple to use and easy to extend.
我使用它来突出显示网页上的代码。它使用简单,易于扩展。
http://code.google.com/p/syntaxhighlighter/
It also supports C#.
它还支持C#。
#1
There's an addin called CopySourceAsHtml which does a pretty neat job. I've used it a few times, but I use a Javascript to do the highlighting on my blog these days (so it's "plaintext readable").
有一个名为CopySourceAsHtml的插件,它做了一个相当干净的工作。我已经使用了几次,但是这些天我使用Javascript在我的博客上进行突出显示(因此它是“明文可读的”)。
#2
You can use existing C to HTML syntax highlighter tools for converting your snippets into HTML and copy&pasting from there. Here's a list of such tools (not exhaustive and in no particular order):
您可以使用现有的C到HTML语法高亮显示工具将您的代码段转换为HTML并从那里复制和粘贴。这是一个这样的工具列表(不详尽,没有特别的顺序):
- GNU Enscript
- GNU Emacs with htmlize.el module allows you to dump a highlighted Emacs buffer as HTML
带有htmlize.el模块的GNU Emacs允许您将突出显示的Emacs缓冲区转储为HTML
There might also exist web services that allow you to copy&paste C code into a form and get highlighted HTML back.
可能还存在Web服务,允许您将C代码复制并粘贴到表单中并重新突出显示HTML。
#3
I use this for highlighting code on webpages. It's simple to use and easy to extend.
我使用它来突出显示网页上的代码。它使用简单,易于扩展。
http://code.google.com/p/syntaxhighlighter/
It also supports C#.
它还支持C#。