Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pweave/formatters/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"):
Expand All @@ -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"]
Expand All @@ -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