texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_tab_comman


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_convert_tab_command): round using %.0f to be more accurate than with %d.
Date: Tue, 23 Jan 2024 14:04:25 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 62c5b6894b * tp/Texinfo/Convert/HTML.pm (_convert_tab_command): round 
using %.0f to be more accurate than with %d.
62c5b6894b is described below

commit 62c5b6894b6d8922d21f77137e80f92843d2c08e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jan 23 20:02:24 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_tab_command): round using
    %.0f to be more accurate than with %d.
    
    * tp/Makefile.tres, tp/t/html_tests.t (fractions_rounding): add a test
    that shows an incorrect percent rounding with %d with perl.
---
 ChangeLog                                     |   8 +
 tp/Makefile.tres                              |   1 +
 tp/Texinfo/Convert/HTML.pm                    |   4 +-
 tp/t/html_tests.t                             |   6 +
 tp/t/results/html_tests/fractions_rounding.pl | 450 ++++++++++++++++++++++++++
 5 files changed, 467 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 86d30fed05..5f253adf8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,14 @@
        _stream_output_encoded, and to get the display width call
        string_width rather than string_width_encoded.
 
+2024-01-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_tab_command): round using
+       %.0f to be more accurate than with %d.
+
+       * tp/Makefile.tres, tp/t/html_tests.t (fractions_rounding): add a test
+       that shows an incorrect percent rounding with %d with perl.
+
 2024-01-22  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Makefile.tres, tp/t/html_tests.t (contents_with_only_top_node)
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 8359e00211..d8171884a7 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -652,6 +652,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/html_tests/footnotestyle_separate_html_text_no_monolithic.pl \
   t/results/html_tests/footnotestyle_separate_late.pl \
   t/results/html_tests/footnotestyle_separate_late/res_html \
+  t/results/html_tests/fractions_rounding.pl \
   t/results/html_tests/headings_after_lone_nodes.pl \
   t/results/html_tests/html_in_copying.pl \
   t/results/html_tests/image_link_prefix.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 37756d380e..4dbe05f2ac 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5909,8 +5909,8 @@ sub _convert_tab_command($$$$$)
   my $cf = $multitable->{'extra'}->{'columnfractions'};
   if ($cf) {
     if (exists($cf->{'extra'}->{'misc_args'}->[$cell_nr-1])) {
-      my $percent = sprintf('%d',
-                             100*$cf->{'extra'}->{'misc_args'}->[$cell_nr-1]);
+      my $percent = sprintf('%.0f',
+                            100. * 
$cf->{'extra'}->{'misc_args'}->[$cell_nr-1]);
       $fractions = " width=\"$percent%\"";
     }
   }
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index 27dc6d6cb3..8ebf766366 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -728,6 +728,12 @@ In top.
 ['end_of_line_in_uref',
 'See the @uref{https://gcc.gnu.org/codingconventions.html#Spelling
 Spelling, terminology and markup} section.'],
+['fractions_rounding',
+'@multitable @columnfractions .19 .30 .29 .22
+@item In contents            @tab In contents                  @tab In 
contents           @tab Not in contents
+@item @code{@@chapter}       @tab @code{@@unnumbered}          @tab 
@code{@@appendix} @tab @code{@@chapheading}
+@end multitable
+'],
 ['spaces_in_line_break_in_verb_w',
 '@w{aaa  bb
 ccc}
diff --git a/tp/t/results/html_tests/fractions_rounding.pl 
b/tp/t/results/html_tests/fractions_rounding.pl
new file mode 100644
index 0000000000..c55dfcfef8
--- /dev/null
+++ b/tp/t/results/html_tests/fractions_rounding.pl
@@ -0,0 +1,450 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'fractions_rounding'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'args' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => '.19 .30 .29 .22'
+                        }
+                      ],
+                      'info' => {
+                        'spaces_after_argument' => {
+                          'text' => '
+'
+                        }
+                      },
+                      'type' => 'line_arg'
+                    }
+                  ],
+                  'cmdname' => 'columnfractions',
+                  'extra' => {
+                    'misc_args' => [
+                      '.19',
+                      '.30',
+                      '.29',
+                      '.22'
+                    ]
+                  },
+                  'info' => {
+                    'spaces_before_argument' => {
+                      'text' => ' '
+                    }
+                  },
+                  'source_info' => {
+                    'line_nr' => 1
+                  }
+                }
+              ],
+              'type' => 'block_line_arg'
+            }
+          ],
+          'cmdname' => 'multitable',
+          'contents' => [
+            {
+              'contents' => [
+                {
+                  'contents' => [
+                    {
+                      'cmdname' => 'item',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'In contents            '
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 1
+                      },
+                      'source_info' => {
+                        'line_nr' => 2
+                      }
+                    },
+                    {
+                      'cmdname' => 'tab',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'In contents                  '
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 2
+                      },
+                      'source_info' => {
+                        'line_nr' => 2
+                      }
+                    },
+                    {
+                      'cmdname' => 'tab',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'In contents           '
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 3
+                      },
+                      'source_info' => {
+                        'line_nr' => 2
+                      }
+                    },
+                    {
+                      'cmdname' => 'tab',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'Not in contents
+'
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 4
+                      },
+                      'source_info' => {
+                        'line_nr' => 2
+                      }
+                    }
+                  ],
+                  'extra' => {
+                    'row_number' => 1
+                  },
+                  'type' => 'row'
+                },
+                {
+                  'contents' => [
+                    {
+                      'cmdname' => 'item',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'args' => [
+                                {
+                                  'contents' => [
+                                    {
+                                      'cmdname' => '@'
+                                    },
+                                    {
+                                      'text' => 'chapter'
+                                    }
+                                  ],
+                                  'type' => 'brace_command_arg'
+                                }
+                              ],
+                              'cmdname' => 'code',
+                              'source_info' => {
+                                'line_nr' => 3
+                              }
+                            },
+                            {
+                              'text' => '       '
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 1
+                      },
+                      'source_info' => {
+                        'line_nr' => 3
+                      }
+                    },
+                    {
+                      'cmdname' => 'tab',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'args' => [
+                                {
+                                  'contents' => [
+                                    {
+                                      'cmdname' => '@'
+                                    },
+                                    {
+                                      'text' => 'unnumbered'
+                                    }
+                                  ],
+                                  'type' => 'brace_command_arg'
+                                }
+                              ],
+                              'cmdname' => 'code',
+                              'source_info' => {
+                                'line_nr' => 3
+                              }
+                            },
+                            {
+                              'text' => '          '
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 2
+                      },
+                      'source_info' => {
+                        'line_nr' => 3
+                      }
+                    },
+                    {
+                      'cmdname' => 'tab',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'args' => [
+                                {
+                                  'contents' => [
+                                    {
+                                      'cmdname' => '@'
+                                    },
+                                    {
+                                      'text' => 'appendix'
+                                    }
+                                  ],
+                                  'type' => 'brace_command_arg'
+                                }
+                              ],
+                              'cmdname' => 'code',
+                              'source_info' => {
+                                'line_nr' => 3
+                              }
+                            },
+                            {
+                              'text' => ' '
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 3
+                      },
+                      'source_info' => {
+                        'line_nr' => 3
+                      }
+                    },
+                    {
+                      'cmdname' => 'tab',
+                      'contents' => [
+                        {
+                          'text' => ' ',
+                          'type' => 'ignorable_spaces_after_command'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'args' => [
+                                {
+                                  'contents' => [
+                                    {
+                                      'cmdname' => '@'
+                                    },
+                                    {
+                                      'text' => 'chapheading'
+                                    }
+                                  ],
+                                  'type' => 'brace_command_arg'
+                                }
+                              ],
+                              'cmdname' => 'code',
+                              'source_info' => {
+                                'line_nr' => 3
+                              }
+                            },
+                            {
+                              'text' => '
+'
+                            }
+                          ],
+                          'type' => 'paragraph'
+                        }
+                      ],
+                      'extra' => {
+                        'cell_number' => 4
+                      },
+                      'source_info' => {
+                        'line_nr' => 3
+                      }
+                    }
+                  ],
+                  'extra' => {
+                    'row_number' => 2
+                  },
+                  'type' => 'row'
+                }
+              ],
+              'type' => 'multitable_body'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'multitable'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_after_argument' => {
+                      'text' => '
+'
+                    }
+                  },
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'end',
+              'extra' => {
+                'text_arg' => 'multitable'
+              },
+              'info' => {
+                'spaces_before_argument' => {
+                  'text' => ' '
+                }
+              },
+              'source_info' => {
+                'line_nr' => 4
+              }
+            }
+          ],
+          'extra' => {
+            'columnfractions' => {},
+            'max_columns' => 4
+          },
+          'info' => {
+            'spaces_before_argument' => {
+              'text' => ' '
+            }
+          },
+          'source_info' => {
+            'line_nr' => 1
+          }
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+$result_trees{'fractions_rounding'}{'contents'}[0]{'contents'}[0]{'extra'}{'columnfractions'}
 = 
$result_trees{'fractions_rounding'}{'contents'}[0]{'contents'}[0]{'args'}[0]{'contents'}[0];
+
+$result_texis{'fractions_rounding'} = '@multitable @columnfractions .19 .30 
.29 .22
+@item In contents            @tab In contents                  @tab In 
contents           @tab Not in contents
+@item @code{@@chapter}       @tab @code{@@unnumbered}          @tab 
@code{@@appendix} @tab @code{@@chapheading}
+@end multitable
+';
+
+
+$result_texts{'fractions_rounding'} = 'In contents            In contents      
            In contents           Not in contents
+@chapter       @unnumbered          @appendix @chapheading
+';
+
+$result_errors{'fractions_rounding'} = [];
+
+
+$result_floats{'fractions_rounding'} = {};
+
+
+
+$result_converted{'html'}->{'fractions_rounding'} = '<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Untitled Document</title>
+
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+
+
+</head>
+
+<body lang="en">
+<table class="multitable">
+<tbody><tr><td width="19%">In contents</td><td width="30%">In contents</td><td 
width="29%">In contents</td><td width="22%">Not in contents</td></tr>
+<tr><td width="19%"><code class="code">@chapter</code></td><td 
width="30%"><code class="code">@unnumbered</code></td><td width="29%"><code 
class="code">@appendix</code></td><td width="22%"><code 
class="code">@chapheading</code></td></tr>
+</tbody>
+</table>
+
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'fractions_rounding'} = [
+  {
+    'error_line' => 'warning: must specify a title with a title command or @top
+',
+    'text' => 'must specify a title with a title command or @top',
+    'type' => 'warning'
+  }
+];
+
+
+1;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]