Skip to content
Christian Ziemski edited this page Mar 7, 2016 · 4 revisions

# Select any text, press Ctrl-Shift-C and it will be surrounded with <code></code> HTML tags.
# Without a selection, an empty <code></code> pair is inserted.
# Install: Put the source below into "WikidPad/user_extensions/codify.py"
# and restart WikidPad.
# Extremely heavily inspired by the URLifyFile plugin.

WIKIDPAD_PLUGIN = (("MenuFunctions",1),)
def describeMenuItems(wiki):
	global nextNumber
	return ((codify, "Codify selection\tCtrl-Shift-C", "Codify selection"),)

def codify(wiki, evt):
	text = wiki.getActiveEditor().GetSelectedText()
	editor = wiki.getActiveEditor()
	editor.ReplaceSelection("<code>")
	bytePos = editor.GetCurrentPos()
	temp = text.strip()
	if len(temp) == 0:
		editor.AddText("</code>")
		editor.GotoPos(bytePos)
	else:
		editor.AddText(text + "</code>")



Note: You might want to surround "codified" block with "<<pre", ">>" tags , too.

Source: http://trac.wikidpad2.webfactional.com/wiki/CoDiFy

Clone this wiki locally