For SharePoint 2010 you could create a custom action to add a button to the ribbon which opens a new page to paste you source code into. Once the user closes the window some Javascript wraps the code into the pre
tags and inserts it at the position of the cursor.
UPDATE: You could use combination of the zoombldr.aspx
page (used to edit the HTML source) and JavaScript code which is used to insert a hyperlink into a Wiki page. That's how I did it (even though mine was for 2007 those haven't changed a lot). Just add a button to the ribbon via custom action which pops up the zoombldr.aspx
page and let the user paste the source into it. Once the page is closed the JavaScript grabs the content and insert it into a wrapped pre
element.
UPDATE2: AFAIK there is no official SharePoint API to insert stuff into a rich-text field. However, here's a piece of JavaScript I just gobbled together (not tested!) to open a dialog and insert the returned code into the rich-text field:
function RTE_InsertSourceCode(strBaseElementID)
{
var docEditor=RTE_GetEditorDocument(strBaseElementID);
var currentContent=new Array;
currentContent.value="";
currentContent.dir=docEditor.dir;
var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
var returnValue=showModalDialog(
variables.aSettings.urlWebRoot+'/_layouts/zoombldr.aspx',
currentContent,
'dialogHeight: 550px; dialogWidth:500px; help: no; status:no; resizable: yes');
if (returnValue != "")
{
returnValue = "<pre class=\"language-powershell\">" + returnValue + "</pre>";
RTE_GetSelection(strBaseElementID).pasteHTML(returnValue);
}
var docTextRange=docEditor.body.createTextRange();
docTextRange.scrollIntoView(false);
if (RTE_UseDynamicHeightSizing(strBaseElementID))
{
RTE_DocEditor_AdjustHeight(strBaseElementID);
}
}
All you have to do now is create your custom action and you should be all set.
For SharePoint 2007 you need to hack into the rich-text editor (note: works only in IE) function RTE_FullHtmlToolBarDefinitionFactory
to add a button to the toolbar which then does the same as above.
I've been doing that some time ago for a SharePoint 2007 Blog and Wiki using the Google Code Prettifier project and it worked so far (with some issues in old IE 6/7 browsers, though).