MakeWikiWord - butscher/WikidPad GitHub Wiki
Here is a script you can use to replace any highlighted word with it's equivalent wrapped in brackets so Frodo => [Frodo]
1) If you go into your \user_extensions\EvalLibrary.py file (copy it from \extensions\ if not available and add the following:
def WWord(editor):
text = editor.GetSelectedText() # Get Text that is selected from the editor
text = text.replace("'", "") # Get rid of all the nasty apostrophes which negate the wikiword
text = text.title() # Properly Capitalize, etc.
text = "[" + text + "]" # Write Wiki Brackets around
editor.ReplaceSelection(text) # Replace the selection with our newly edited text
2) Restart WikidPad 3) Add the following to the page you want this to work on:
<% 1: lib.WWord(editor) %>
4) Highlight a word and press Control+1 and it should do what you want.
Q: I'm trying to figure out how to integrate this as a global function so if anyone knows of a way to do that, please let me know.
A: See UrlifyFile
Added by '''wizel10''':
# Select a word, press CTRL-Shift-U and it will turn the wrod into a wikiWord
# Install: Put the source below into "WikidPad/user_extensions/WWord.py"
# and restart WikidPad.
WIKIDPAD_PLUGIN = (("MenuFunctions",1),)
def describeMenuItems(wiki):
return ((WWord, "WWord\tCtrl-Shift-U", "Convert Word"),)
def WWord(wiki, evt):
text = wiki.getActiveEditor().GetSelectedText() # Get Text that is selected from the editor
text = text.replace("'", "") # Get rid of all the nasty apostrophes which negate the wikiword
text = text.title() # Properly Capitalize, etc.
text = "[" + text + "]" # Write Wiki Brackets around
wiki.getActiveEditor().ReplaceSelection(text) # Replace the selection with our newly edited text
Added by '''jaysen''' - heres an adaptation that will work with many words ("test one two" changes to "TestOneTwo")
# Select a word, press CTRL-Shift-W and it will turn the word into a wikiWord
# Install: Put the source below into "WikidPad/user_extensions/WWord.py"
# and restart WikidPad.
WIKIDPAD_PLUGIN = (("MenuFunctions",1),)
def describeMenuItems(wiki):
return ((WWord, "WWord\tCtrl-Shift-W", "Make WikiWord"),)
def WWord(wiki, evt):
text = wiki.getActiveEditor().GetSelectedText() # Get Text that is selected from the editor
text = text.replace("'", "") # Get rid of all the nasty apostrophes which negate the wikiword
words = text.rsplit(' ')
newtext=''
if len(words) > 1:
for w in words:
w = w.title()
newtext = newtext + w
else:
#text = text.title() # Properly Capitalize, etc.
newtext = "[" + text + "]" # Write Wiki Brackets around
wiki.getActiveEditor().ReplaceSelection(newtext) # Replace the selection with our newly edited text