| 42 | | if not hasattr(hdf, 'footnotes'): |
|---|
| 43 | | hdf.footnotes = [] |
|---|
| 44 | | hdf.footnote_set = 1 |
|---|
| 45 | | # Display and clear footnotes... |
|---|
| 46 | | if not args: |
|---|
| 47 | | out = StringIO() |
|---|
| 48 | | out.write('<div class="footnotes">\n'); |
|---|
| 49 | | out.write('<hr style="width: 10%; padding: 0; margin: 2em 0 1em 0;"/>\n'); |
|---|
| 50 | | out.write('<ol style="padding: 0 0 0 1em; margin: 0;">\n') |
|---|
| 51 | | for i, v in enumerate(hdf.footnotes): |
|---|
| 52 | | id = "%i.%i" % (hdf.footnote_set, i + 1) |
|---|
| 53 | | out.write('<li style="list-style: none;" id="FootNote%s"><a style="font-weight: bold;" href="#FootNoteRef%s">%i.</a> %s</li>\n' % (id, id, i + 1, wiki_to_oneliner(unescape(v), env))) |
|---|
| 54 | | out.write('</ol>\n') |
|---|
| 55 | | out.write('</div>\n'); |
|---|
| 56 | | hdf.footnotes = [] |
|---|
| 57 | | hdf.footnote_set += 1 |
|---|
| 58 | | return out.getvalue() |
|---|
| 59 | | else: |
|---|
| 60 | | id = len(hdf.footnotes) + 1 |
|---|
| 61 | | try: |
|---|
| 62 | | id = int(args) |
|---|
| 63 | | except ValueError: |
|---|
| 64 | | existing = None |
|---|
| 65 | | for index, note in enumerate(hdf.footnotes): |
|---|
| 66 | | if args == note: |
|---|
| 67 | | existing = note |
|---|
| 68 | | id = index + 1 |
|---|
| 69 | | break |
|---|
| 70 | | if not existing: |
|---|
| 71 | | hdf.footnotes.append(args) |
|---|
| 72 | | full_id = "%i.%i" % (hdf.footnote_set, id) |
|---|
| 73 | | return '<sup><a title="%s" style="font-size: 8pt; font-weight: bold;" id="FootNoteRef%s" href="#FootNote%s">%i</a></sup>' % (args[:16] + "...", full_id, full_id, id) |
|---|
| | 42 | if not hasattr(hdf, 'footnotes'): |
|---|
| | 43 | hdf.footnotes = [] |
|---|
| | 44 | hdf.footnote_set = 1 |
|---|
| | 45 | # Display and clear footnotes... |
|---|
| | 46 | if not args: |
|---|
| | 47 | out = StringIO() |
|---|
| | 48 | out.write('<div class="footnotes">\n'); |
|---|
| | 49 | out.write('<hr style="width: 10%; padding: 0; margin: 2em 0 1em 0;"/>\n'); |
|---|
| | 50 | out.write('<ol style="padding: 0 0 0 1em; margin: 0;">\n') |
|---|
| | 51 | for i, v in enumerate(hdf.footnotes): |
|---|
| | 52 | id = "%i.%i" % (hdf.footnote_set, i + 1) |
|---|
| | 53 | out.write('<li style="list-style: none;" id="FootNote%s"><a style="font-weight: bold;" href="#FootNoteRef%s">%i.</a> %s</li>\n' % (id, id, i + 1, wiki_to_oneliner(unescape(v), env))) |
|---|
| | 54 | out.write('</ol>\n') |
|---|
| | 55 | out.write('</div>\n'); |
|---|
| | 56 | hdf.footnotes = [] |
|---|
| | 57 | hdf.footnote_set += 1 |
|---|
| | 58 | return out.getvalue() |
|---|
| | 59 | else: |
|---|
| | 60 | id = len(hdf.footnotes) + 1 |
|---|
| | 61 | try: |
|---|
| | 62 | id = int(args) |
|---|
| | 63 | except ValueError: |
|---|
| | 64 | existing = None |
|---|
| | 65 | for index, note in enumerate(hdf.footnotes): |
|---|
| | 66 | if args == note: |
|---|
| | 67 | existing = note |
|---|
| | 68 | id = index + 1 |
|---|
| | 69 | break |
|---|
| | 70 | if not existing: |
|---|
| | 71 | hdf.footnotes.append(args) |
|---|
| | 72 | full_id = "%i.%i" % (hdf.footnote_set, id) |
|---|
| | 73 | return '<sup><a title="%s" style="font-size: 8pt; font-weight: bold;" id="FootNoteRef%s" href="#FootNote%s">%i</a></sup>' % (args[:16] + u"...", full_id, full_id, id) |
|---|