def applyPlugins2(self, s): """ a lighter plugin applier, just for images and wiki links, some of them result from templates expanded by the mediawiki engine @param s the string to be processed @return the processed string """ #== the parsers of every plugin are applied, then the image parser parsers=[imageParser(imgFun), wikiLinkParser(linkFun)] for parser in parsers: s=parser.sub(s) return s
def applyPlugins(self, s): """ fixes the strings "<math>" and "</math>", then pre-processes a few simple templates which have a precise definition for LaTeX, then processes the images. @param s the string to be processed @return the processed string """ s=s.replace("<math>","$") s=s.replace("</math>","$") #== recodes File:.*.jpg, Fichier:.*.jpg, etc. into Image: templates s=re.sub(r"\[\[(File|Fichier):([-_0-9a-zA-Z]*)\.(jpg|JPG|png|PNG|gif|GIF)",r"[[Image:\2.\3",s) #== the parsers of every plugin are applied, then the image parser parsers=map(lambda c: c(), plugins)+[imageParser(imgFun)] for parser in parsers: s=parser.sub(s) return s