Skip to content

Commit

Permalink
Enhance graphics options parsing.
Browse files Browse the repository at this point in the history
Fix problem with multiples options like
'width=216.81pt,keepaspectratio=true'
  • Loading branch information
nennigb committed Jul 3, 2024
1 parent 25c744b commit 071287c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions amc2moodle/amc2moodle/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ def _graphics(self):
# conversion des notations d'alignement
align = {'ltx_align_right': 'right', 'ltx_align_left': 'left',
'ltx_centering': 'center'}

dimensions = ('width', 'height')
for Ii in Ilist:
try:
img_name = Ii.attrib['candidates'].split(',')[-1] # get the last candidates
Expand All @@ -1008,11 +1008,15 @@ def _graphics(self):
img_align = Ii.attrib['class']
else:
img_align = 'ltx_centering' # default value center !
# try for option
# try for options
if 'options' in Ii.attrib:
img_options = Ii.attrib['options']
img_size = img_options.split('=')[-1] # il reste pt, mais cela ne semble pas poser de pb
img_dim = img_options.split('=')[0]
# Convert options into a dict and select usefull key
img_options_dict = dict([s.split('=') for s in img_options.split(',')])
for key, val in img_options_dict.items():
if key in dimensions:
img_size = val # il reste pt, mais cela ne semble pas poser de pb
img_dim = key
else:
img_options = ''
img_size = self.options['default_img_width']
Expand Down

0 comments on commit 071287c

Please sign in to comment.