Ejemplo n.º 1
0
 def _handler(env) :
     get_counter("subsubsection").increment()
     id = generate_id("subsubsection", get_counter("page"), get_counter("section"), get_counter("subsection"), get_counter("subsubsection"))
     set_anchor_reference(token_env, id, text)
     return (ParagraphToken() + InhibitParagraphToken() + get_anchor_by_id(id) + InhibitParagraphToken()
             + StringToken("<H4>"+counters_to_string("section", "subsection", "subsubsection")+". ") + text + StringToken("</H4>")
             + ParagraphToken())
Ejemplo n.º 2
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>")
Ejemplo n.º 3
0
 def _handler(env) :
     get_counter("figure").increment()
     id = generate_id("figure", get_counter("page"), get_counter("figure"))
     set_anchor_reference(outer_token_env, id, StringToken(str(counters_to_string("figure"))))
     p = escape_env["_figure_placement"].eval(env)
     if type(p) is not StringToken :
         p.fail("Figure placement must be a string.")
     o = (ParagraphToken() + InhibitParagraphToken() + get_anchor_by_id(id) + InhibitParagraphToken()
          + StringToken("<div class=\"figure figure_"+p.s+"\">") + out + StringToken("</div>")
          + ParagraphToken())
     return o
Ejemplo n.º 4
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