I’ve played with a few tools to post code to my blog and for sharing documentation. I’m mostly interested in pasting T-SQL from SQL Server Management Studio(pasting RTF), but I also paste PowerShell scripts and batch files.
Now I’m trying the Insert Formatted Clipboard plugin from Noah Coad along with Windows Live Writer – both new to me with this post. There was a painful install process(see comments by ITSOLVE) under Vista that involved renaming an .MSI file, executing msiexec from the command prompt, and manually copying a DLL file. In XP I had no problems with the install.
On to usage. I copied the T-SQL from SSMS
Ahh. Cleanly converted HTML from an RTF paste – with inline styles. Hallelujah! You may notice that the pasted text does not contain the proper monospaced typeface. I’m ok with that, as I would normally wrap that text in a border with a monospaced font. Read on.
Sometimes I just want to wrap the code with a border following the styles created at Format My Source Code for Blogging.
So, using the above html I can paste inside the <code> </code> tag and it comes out like so:
SELECT '-- ' + cast(@@SERVERNAME as char(16)), cast(db_name() as char(20)), getdate()
If I’m careful within Windows Live Writer I can highlight & copy the text that was created from the Insert >> Formatted Clipboard… step, then double-click on the newly created empty border and paste right into the border style without using the Source Tab.
The other Windows Live Writer plugin used above to display the <pre> style from Format My Source Code for Blogging was Code Snippet by Leo Vildosola.
If you’d like to dive even further into RTF, HTML, and related macros for Visual Studio, see Steve Nyholm’s blog.