Making and Capitalizing aliases

20 weergaven
Naar het eerste ongelezen bericht

Will

ongelezen,
18 aug 2013, 18:49:3718-08-2013
aan wikidpa...@googlegroups.com
This script generates aliases for the different combinations of possible capitalizations for wiki page title.

If your page is Hello world, this script will generate

[alias: hello world]
[alias: hello World]
[alias: Hello World]

I have no idea if anyone else will find this useful or if this is the right place to post it. Anyway, thanks for developing this guys. I love Wikipad.

<% 1:
import math
editor.GotoPos(editor.GetLength())
willsCurrentWikiTitle = str(editor.getLoadedDocPage().wikiWord )
willsCurrentWikiWords = willsCurrentWikiTitle.split()
willsCurrentWikiWordsLength = len(willsCurrentWikiWords)

for x in range(0, math.pow(2, willsCurrentWikiWordsLength)):   
    line = ''
    for y in range(0, willsCurrentWikiWordsLength):
        wordsWhichGetCapitalized = str(bin(x))
        bitwiseCompared = int(math.pow(2, willsCurrentWikiWordsLength)-1)
        bitwiseCurrent = x       
        capitalized = bitwiseCompared & bitwiseCurrent
        padZerosNumber = len(str(bin(bitwiseCompared))) - len(str(bin(bitwiseCurrent)))
        padZeros = ""
        for z in range(0, padZerosNumber):
            padZeros += '0'
       
        joinedString = str(bin(capitalized))[2:]
        joinedString = padZeros + joinedString
       
     
        if joinedString[y] == '1':
           
            if y==0:
                line += willsCurrentWikiWords[y].capitalize()
            else:
                line +=' '
                line += willsCurrentWikiWords[y].capitalize()
        else:
            if y==0:
                line += willsCurrentWikiWords[y].lower()
            else:
                line +=' '
                line += willsCurrentWikiWords[y].lower()
    if line != str(editor.getLoadedDocPage().wikiWord):
        editor.AddText('[alias:')
        editor.AddText(line)
        editor.AddText(']\n')
editor.GotoPos(0)
%>
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten