import urllib, string
WIKIDPAD_PLUGIN = (("MenuFunctions",1),)
def describeMenuItems(wiki):
global nextNumber
return ((anchorify, "Anchorify selection\tCtrl-Shift-Z", "Anchorify selection"),)
def anchorify(wiki, evt):
text = wiki.getActiveEditor().GetSelectedText()
editor = wiki.getActiveEditor()
if text.find("http") != 0:
editor.ReplaceSelection("<a href=\"\" target=\"_blank\">")
bytePos = editor.GetCurrentPos()
temp = string.strip(text)
if len(temp) == 0:
editor.AddText("</a>")
editor.GotoPos(bytePos)
else:
editor.AddText(text + "</a>")
else:
editor.ReplaceSelection("<a href=\"")
bytePos = editor.GetCurrentPos()
temp = string.strip(text)
if len(temp) == 0:
editor.AddText("\" target=\"_blank\"></a>")
editor.GotoPos(bytePos)
else:
editor.AddText(text + "\" target=\"_blank\"></a>")