Introduction
I sometimes need to post my cpp source code to the BBS. Because the BBS removes all html tag and encloses pre tag. I need to do following routine work
- duplicate source code of the selected area
- replace html escape charactors ("<", ">", "&")
- untabify (replace TAB to Equivalent spaces)
So I write a macro for VisualStudio.NET. This is simple but convenient tool for me.
Usage
It's very easy. Select the source code area you want to convert and call this macro. Then converted code was pasted to clipboard.
Code
Sub Src2Html()
DTE.UndoContext.Open("ToHTML")
Try
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocumentSelection
DTE.Find.MatchCase = True
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.FindWhat = "&"
DTE.Find.ReplaceWith = "&"
DTE.Find.Execute()
DTE.Find.FindWhat = "<"
DTE.Find.ReplaceWith = "<"
DTE.Find.Execute()
DTE.Find.FindWhat = ">"
DTE.Find.ReplaceWith = ">"
DTE.Find.Execute()
DTE.ActiveDocument.Selection.Untabify()
DTE.ActiveDocument.Selection.Copy()
Finally
DTE.UndoContext.Close()
DTE.ActiveDocument.Undo()
End Try
End Sub
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.