1 """
   2     MoinMoin - FootNote Macro
   3 
   4     Copyright (c) 2002 by Jürgen Hermann <jh@web.de>
   5     All rights reserved, see COPYING for details.
   6 
   7     Collect and emit footnotes. Note that currently footnote
   8     text cannot contain wiki markup.
   9 
  10     $Id: FabianFranz_2fFootNote_2epy,v 1.1 2002/06/19 01:43:05 linuxwiki Exp $
  11 """
  12 
  13 # Imports
  14 import string
  15 #from MoinMoin.i18n import _
  16 
  17 
  18 def execute(macro, args):
  19     # create storage for footnotes
  20     if not hasattr(macro.request, 'footnotes'):
  21         macro.request.footnotes = []
  22     
  23     if not args:
  24         return emit_footnotes(macro.request, macro.formatter)
  25     else:
  26         # store footnote and emit number
  27         macro.request.footnotes.append(args)
  28         idx = str(len(macro.request.footnotes))
  29         return "%s%s%s" % (
  30             macro.formatter.sup(1),
  31             macro.formatter.anchorlink('moin_footnote' + idx, idx),
  32             macro.formatter.sup(0),)
  33 
  34     # nothing to do or emit
  35     return ''
  36 
  37 
  38 #Need some more Variables for formatting, if not present no formatting will be used
  39 
  40 def emit_footnotes(request, formatter, hasparser=0, Parser=0, form=0):
  41     # emit collected footnotes
  42     if request.footnotes:
  43         result = ['____']
  44         for idx in range(len(request.footnotes)):
  45             result.append(formatter.linebreak(0))
  46             result.append(formatter.anchordef('moin_footnote%d' % (idx+1)))
  47             result.append(formatter.code(1))
  48             result.append(formatter.sup(1))
  49             result.append(string.replace('%4d ' % (idx+1), ' ', formatter.hardspace))
  50             result.append(formatter.sup(0))
  51             result.append(formatter.code(0))
  52             if hasparser==1:
  53 	      formatter.in_p=1		# Don't do a <p> !
  54               result.append(Parser(request.footnotes[idx],'').format(formatter,form,0)) #format footnotes due to security
  55             else:
  56               result.append(request.footnotes[idx])
  57         request.footnotes = []
  58         return string.join(result, '')
  59 
  60     return ''

FabianFranz/FootNote.py (zuletzt geändert am 2007-12-23 22:45:39 durch localhost)