def linkFun(d): """ the standard custom parser for a dictionary coming from a wikilink """ hashtag=uicimd5.digest(d["target"]) code="\\hyperref[%s]{%s}" %(hashtag,d["anchor"]) return code
def transform_heading_to_sect(s, state, pattern, replacement): """ transforms a heading to a section of adapted level @param s the string to transform @param state state of the automaton @param pattern a regexp to recognize the heading @param replacement a string to replace the pattern with matched substrings @return the transformed string """ for m in re.finditer(pattern, s): anchor="%s#%s" %(state.currentPage, m.group(1)) hashtag=uicimd5.digest(anchor) s=s[:m.start()]+m.expand(replacement)+s[m.end():] s=s %(hashtag, anchor) return s