Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance graphics options parsing. #83

Merged
merged 1 commit into from
Jul 4, 2024
Merged
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
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
Loading