SF.net SVN: docutils:[9926] trunk/docutils/docutils/writers

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9926
          http://sourceforge.net/p/docutils/code/9926
Author:   milde
Date:     2024-09-11 07:19:41 +0000 (Wed, 11 Sep 2024)
Log Message:
-----------
Fixes for "scale" attribute handling in ODT and LaTeX writer.

Remove redundant code in the ODT writer:
Scale is validated as "non-negative integer" by the parser.
No need to validate again.

Use the "generic" numeral format instead of "float"
in the LaTeX writer (%f -> %g).

Modified Paths:
--------------
    trunk/docutils/docutils/writers/latex2e/__init__.py
    trunk/docutils/docutils/writers/odf_odt/__init__.py

Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py	2024-09-10 18:25:17 UTC (rev 9925)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py	2024-09-11 07:19:41 UTC (rev 9926)
@@ -2435,7 +2435,7 @@
                 'height=%s' % self.to_latex_length(attrs['height']))
         if 'scale' in attrs:
             include_graphics_options.append(
-                'scale=%f' % (attrs['scale'] / 100.0))
+                'scale=%g' % (attrs['scale'] / 100.0))
         if 'width' in attrs:
             include_graphics_options.append(
                 'width=%s' % self.to_latex_length(attrs['width']))

Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py	2024-09-10 18:25:17 UTC (rev 9925)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py	2024-09-11 07:19:41 UTC (rev 9926)
@@ -2236,14 +2236,8 @@
     def get_image_scale(self, node):
         if 'scale' in node.attributes:
             scale = node.attributes['scale']
-            try:
-                scale = int(scale)
-            except ValueError:
+            if scale < 1:
                 self.document.reporter.warning(
-                    'Invalid scale for image: "%s"' % (
-                        node.attributes['scale'], ))
-            if scale < 1:       # or scale > 100:
-                self.document.reporter.warning(
                     'scale out of range (%s), using 1.' % (scale, ))
                 scale = 1
             scale = scale * 0.01

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.