forked from butscher/WikidPad
-
Notifications
You must be signed in to change notification settings - Fork 0
BetterFootNotes
Christian Ziemski edited this page Mar 7, 2016
·
4 revisions
"""
BetterFootNotes
Usage from WikidPad:
To create the footnote marker add a [:fn:Content of my footnote] in the page content where the marker is desired.
The content of the footnote will show in the list of footnotes. To show this list, add [:fl:] wherever the list is desired.
If the "footnotes as wiki words"-option is set, it will still work.
Licence: cc0
"""
WIKIDPAD_PLUGIN = (('InsertionByKey', 1),)
NUMBER_OF_FIRST_NOTE = 1
def describeInsertionKeys(ver, app):
return ((u'fn', ('wikidpad_language',), FootNoteHandler),(u'fl', ('wikidpad_language',), FootListHandler))
class FootNoteHandler(object):
"""
Handles the footnotes in the running text
"""
def __init__(self, app):
self.app = app
def taskStart(self, exporter, exportType):
# needs to be global
global list_of_footnotes
list_of_footnotes = []
self.nr = NUMBER_OF_FIRST_NOTE - 1
def taskEnd(self):
pass
def getExtraFeatures(self):
return ()
def createContent(self, exporter, exportType, insToken):
list_of_footnotes.append(insToken.getString()[5:-1])
self.nr += 1
#TODO: add footlist at the end of the text when first footnote given
return '<sup><a name="text_fn%s" href="#list_fn%s">%s</a></sup>'%(self.nr,self.nr,self.nr)
class FootListHandler(object):
"""
Handles the list of the footnotes at the end of the text
"""
def __init__(self, app):
self.app = app
def taskStart(self, exporter, exportType):
pass
def taskEnd(self):
pass
def getExtraFeatures(self):
return ()
def createContent(self, exporter, exportType, insToken):
endtext = []
for i,text in enumerate(list_of_footnotes):
endtext.append('<small><sup><a name="list_fn%s" href="#text_fn%s">%s</a></sup> %s</small>'
%(i+NUMBER_OF_FIRST_NOTE,i+NUMBER_OF_FIRST_NOTE,i+NUMBER_OF_FIRST_NOTE,text))
return '\n'.join(endtext)
Source: http://trac.wikidpad2.webfactional.com/wiki/BetterFootNotes