-
Notifications
You must be signed in to change notification settings - Fork 5
WordCountInsertion
Michael Butscher edited this page Jan 23, 2021
·
1 revision
import os, urllib import wx ''' A Insertion plugin for WikidPad to count the words on the page Written by Eric Tolman ([email protected]) ''' WIKIDPAD_PLUGIN = (("InsertionByKey", 1),) def describeInsertionKeys(ver, app): """ Adds a word count insertion. Examples [:wordcount:] Outputs the word count """ return ((u"wordcount", ("wikidpad_language",), WordCountHandler),) class WordCountHandler: """ Class fulfilling the "insertion by key" protocol. """ def __init__(self, app): self.app = app def taskStart(self, exporter, exportType): pass def taskEnd(self): pass def createContent(self, exporter, exportType, insToken): wiki = exporter.mainControl editor = wiki.getActiveEditor() text = editor.GetText() return str(len(text.split(None))) def getExtraFeatures(self): return ()