wiki:WordCountInsertion
import os, urllib
import wx

''' 
A Insertion plugin for WikidPad to count the words on the page 

Written by Eric Tolman (tolmaneric@gmail.com)
'''
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 ()

Last modified 6 years ago Last modified on Nov 12, 2011 12:19:55 AM