Пример #1
0
 def _handler(env) :
     if not token_env.has_key("_page_footnotes") :
         raise stream.failure("Footnotes can only appear within a page")
     get_counter("footnote").increment()
     id = generate_id("footnote", get_counter("page"), get_counter("footnote"))
     make_label(token_env, "ref_"+id, "ref_"+id, "^")
     token_env["_page_footnotes"].append((id, footnote))
     return get_anchor_by_id("ref_"+id) + StringToken("<sup>") \
         + make_reference(token_env, StringToken("#" + id), None) \
         + StringToken("</sup>")
Пример #2
0
 def eval_footnotes(footnotes) :
     oldlenfoot = 0
     lenfoot = 0
     fout = StringToken("")
     while len(footnotes) > lenfoot :
         oldlenfoot = lenfoot
         lenfoot = len(footnotes)
         out = StringToken("")
         for (num, (id, footnote)) in zip(xrange(oldlenfoot+1,lenfoot+1), footnotes[oldlenfoot:lenfoot]) :
             make_label(token_env, id, id, StringToken("[%d]" % num))
             
             out += HorizontalLineToken() + InhibitParagraphToken() + get_anchor_by_id(id) \
                 + InhibitParagraphToken() \
                 + StringToken("<div class=\"footnote\">\n<sup>") \
                 + make_reference(token_env, StringToken("#ref_" + id), StringToken("[%d]" % num)) \
                 + StringToken("</sup> ") \
                 + footnote \
                 + StringToken("</div>\n")
         fout += out.eval({})
     return fout