from match import Match def markup_link_syntax(text): """ markup the link-syntax ` => somewhere ` in the text block """ return (text & Match(r"(?m)(^|\s)\=\>\"([^\"]*)\"") >> r"\1\2" & Match(r"(?m)(^|\s)\=\>\'([^\']*)\'") >> r"\1\2" & Match(r"(?m)(^|\s)\=\>\s(\w[\w.]*\w\(\d+\))") >> r"\1\2" & Match(r"(?m)(^|\s)\=\>\s([^\s\,\.\!\?]+)") >> r"\1\2") class CommentMarkup: """ using a structure having a '.comment' item - it does pick it up and enhances its text with new markups so that they can be represented in xml. Use self.xml_text() to get markup text (knows 'this function') """ def __init__(self, header = None): self.header = header self.text = None # xml'text def get_filename(self): if self.header is None: return None return self.header.get_filename() def parse(self, header = None): if header is not None: self.header = header if self.header is None: return False comment = self.header.comment try: comment = self.header.get_otherlines() except Exception, e: pass mode = "" text = "" for line in comment.split("\n"): check = Match() if line & check(r"^\s?\s?\s?[*]\s+[*]\s(.*)"): if mode != "ul": if mode: text += ""+mode+">" mode = "ul" ; text += "<"+mode+">" line = check.group(1) text += "
"+self.markup_para_line(line)+"
")
.replace("