summaryrefslogtreecommitdiff
path: root/docutils/parsers/rst/directives/images.py
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2009-05-19 08:45:27 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2009-05-19 08:45:27 +0000
commit174adb55f795a8ed7a83d05001b4c74b5fd10131 (patch)
treeb9efed442d062050aa48e62f8f3cbabeeaf2679e /docutils/parsers/rst/directives/images.py
parent4dd530145f3ed7aa26385fd2b529fe1754a229b7 (diff)
downloaddocutils-174adb55f795a8ed7a83d05001b4c74b5fd10131.tar.gz
Allow legth and percentage values in "figwidth" argument and percent sign in
"scale" argument of figure and image directives. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5952 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/parsers/rst/directives/images.py')
-rw-r--r--docutils/parsers/rst/directives/images.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py
index 59323bba0..3f5dd9bc4 100644
--- a/docutils/parsers/rst/directives/images.py
+++ b/docutils/parsers/rst/directives/images.py
@@ -40,7 +40,7 @@ class Image(Directive):
option_spec = {'alt': directives.unchanged,
'height': directives.length_or_unitless,
'width': directives.length_or_percentage_or_unitless,
- 'scale': directives.nonnegative_int,
+ 'scale': directives.percentage,
'align': align,
'target': directives.unchanged_required,
'class': directives.class_option}
@@ -101,7 +101,7 @@ class Figure(Image):
if argument.lower() == 'image':
return 'image'
else:
- return directives.nonnegative_int(argument)
+ return directives.length_or_percentage_or_unitless(argument, 'px')
option_spec = Image.option_spec.copy()
option_spec['figwidth'] = figwidth_value
@@ -110,15 +110,9 @@ class Figure(Image):
has_content = True
def run(self):
- figwidth = self.options.get('figwidth')
- if figwidth:
- del self.options['figwidth']
- figclasses = self.options.get('figclass')
- if figclasses:
- del self.options['figclass']
- align = self.options.get('align')
- if align:
- del self.options['align']
+ figwidth = self.options.pop('figwidth', None)
+ figclasses = self.options.pop('figclass', None)
+ align = self.options.pop('align', None)
(image_node,) = Image.run(self)
if isinstance(image_node, nodes.system_message):
return [image_node]