Skip to content
Christian Ziemski edited this page Mar 7, 2016 · 4 revisions
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 ()

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

Clone this wiki locally