diff --git a/pweave/formatters/rst.py b/pweave/formatters/rst.py index 4c7bb67..b2857a4 100644 --- a/pweave/formatters/rst.py +++ b/pweave/formatters/rst.py @@ -14,6 +14,7 @@ def initformat(self): figfmt='.png', extension='rst', width='15 cm', + label='label', doctype='rst') self.fig_mimetypes = ["image/png", "image/jpg"] self.mimetypes = ["text/restructuredtext"] @@ -22,23 +23,23 @@ def initformat(self): def formatfigure(self, chunk): fignames = chunk['figure'] caption = chunk['caption'] + label = chunk['label'] width = chunk['width'] result = "" figstring = "" for fig in fignames: - figstring += ('.. image:: %s\n :width: %s\n\n' % (fig, width)) + figstring += ('.. image:: %s\n :name: %s\n :width: %s\n\n' % (fig, label, width)) if chunk['caption']: result += (".. figure:: %s\n" + " :name: %s\n" " :width: %s\n\n" - " %s\n\n" % (fignames[0], width, caption)) + " %s\n\n" % (fignames[0], label, width, caption)) else: result += figstring return result - - def _indent(self, text): """Indent blocks for formats where indent is significant""" if not text.startswith("\n"): @@ -64,6 +65,7 @@ def initformat(self): figfmt='.*', savedformats=['.png', '.pdf'], extension='rst', + label='label', width='15 cm', doctype='rst') self.fig_mimetypes = ["image/png", "image/jpg"] @@ -73,17 +75,19 @@ def initformat(self): def formatfigure(self, chunk): fignames = chunk['figure'] caption = chunk['caption'] + label = chunk['label'] width = chunk['width'] result = "" figstring = "" for fig in fignames: - figstring += ('.. image:: %s\n :width: %s\n\n' % (fig, width)) + figstring += ('.. image:: %s\n :name: %s\n :width: %s\n\n' % (fig, label, width)) if chunk['caption']: - result += (".. figure:: %s\n" \ - " :width: %s\n\n" \ - " %s\n\n" % (fignames[0], width, caption)) + result += (".. figure:: %s\n" + " :name: %s\n" + " :width: %s\n\n" + " %s\n\n" % (fignames[0], label, width, caption)) else: result += figstring return result