[Moin-devel] CVS: MoinMoin/macro FootNote.py,1.1,1.2

J?rgen Hermann jhermann at users.sourceforge.net
Thu Jan 24 15:26:03 EST 2002


Update of /cvsroot/moin/MoinMoin/macro
In directory usw-pr-cvs1:/tmp/cvs-serv2102/macro

Modified Files:
	FootNote.py 
Log Message:
Auto-emit pending footnotes when page ends


Index: FootNote.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/macro/FootNote.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FootNote.py	2002/01/24 23:10:48	1.1
--- FootNote.py	2002/01/24 23:25:22	1.2
***************
*** 20,47 ****
      if not hasattr(macro.request, 'footnotes'):
          macro.request.footnotes = []
- 
- 
-     def anchordef(self, name):
-         return '<a name="%s"></a>' % name
- 
-     def anchorlink(self, name, text):
-         return '<a href="#%s">%s</a>' % (name, cgi.escape(text))
- 
      
      if not args:
!         # emit collected footnotes
!         if macro.request.footnotes:
!             result = ['____']
!             for idx in range(len(macro.request.footnotes)):
!                 result.append(macro.formatter.linebreak(0))
!                 result.append(macro.formatter.anchordef('moin_footnote%d' % (idx+1)))
!                 result.append(macro.formatter.code(1))
!                 result.append(macro.formatter.sup(1))
!                 result.append(string.replace('%4d ' % (idx+1), ' ', macro.formatter.hardspace))
!                 result.append(macro.formatter.sup(0))
!                 result.append(macro.formatter.code(0))
!                 result.append(macro.request.footnotes[idx])
!             macro.request.footnotes = []
!             return string.join(result, '')
      else:
          # store footnote and emit number
--- 20,26 ----
      if not hasattr(macro.request, 'footnotes'):
          macro.request.footnotes = []
      
      if not args:
!         return emit_footnotes(macro.request, macro.formatter)
      else:
          # store footnote and emit number
***************
*** 54,57 ****
--- 33,55 ----
  
      # nothing to do or emit
+     return ''
+ 
+ 
+ def emit_footnotes(request, formatter):
+     # emit collected footnotes
+     if request.footnotes:
+         result = ['____']
+         for idx in range(len(request.footnotes)):
+             result.append(formatter.linebreak(0))
+             result.append(formatter.anchordef('moin_footnote%d' % (idx+1)))
+             result.append(formatter.code(1))
+             result.append(formatter.sup(1))
+             result.append(string.replace('%4d ' % (idx+1), ' ', formatter.hardspace))
+             result.append(formatter.sup(0))
+             result.append(formatter.code(0))
+             result.append(request.footnotes[idx])
+         request.footnotes = []
+         return string.join(result, '')
+ 
      return ''
  





More information about the Moin-devel mailing list