Exemplo 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())
Exemplo 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>")
Exemplo 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
Exemplo n.º 4
0
def begin_page_environment(stream, char_env, escape_env) :
    file = parse_one(stream, char_env, escape_env, [])
    try :
        file = file.eval({})
    except AttributeError :
        raise stream.failure("Page file name must not be parameterized.")
    if type(file) != StringToken :
        raise stream.failure("File name must be a string.")
    
    get_counter("page").increment()
    pageid = generate_id("page", get_counter("page"))
    escape_env["_curr_pageid"] = pageid
    add_counter("footnote")

    set_page_reference(escape_env, pageid, file.s)
    return (char_pretty_text,
            escape_env.extend({"_page_footnotes" : []}))