def emit_bb_rootlink_start(name, attrs): rootpath = blagvars.getvar("root") if not "id" in attrs.keys(): print "Warning: no link given to bb:rootlink" return "bb:rootlink without id" else: target = attrs.getValue("id") tag_str = '<a href="{}{}">'.format(rootpath, target) return tag_str
def emit_bb_var_start(name, attrs): if not "name" in attrs.keys(): print "Warning: unnamed variable!" return "blagblag:unknown variable" else: varname = attrs.getValue("name") var_value = blagvars.getvar(varname) if not var_value: print "Warning: unknown variable {}".format(varname) return "blagblag:no variable {}".format(varname) return str(var_value)
def characters(self, c): if not self.bb_title_ended: return maxwords = blagvars.getvar("chapeau_words") if (not self.bb_chap_started and self.word_counter >= maxwords) or (self.bb_chap_ended is True): return if maxwords is None: maxwords = defaults.CHAPEAU_WORDS print "Warning: no maximum number of words defined for" + " the chapeau.\n" print "Settling for default of {}".format(maxwords) self.chap += c self.last_word_counter = self.word_counter word_counter = len(self.chap.split(" "))