+def render_latex(wldoc, prefix="latex"):
+ """
+ Renders <latex>CODE</latex> as images and returns
+ (changed_wldoc, [ (epub_filepath1, latexfragment_object1), ... ]
+"""
+ root = wldoc.edoc.getroot()
+ latex_nodes = root.findall(".//latex")
+ images = []
+ for ln in latex_nodes:
+ fragment = LatexFragment(ln.text, resize=40)
+ images.append((os.path.join(prefix, fragment.filename), fragment))
+ ln.tag = "img"
+ ln.text = os.path.join(prefix, fragment.filename)
+
+ return wldoc, images
+
+