texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/Converter.pm (format_comment


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Converter.pm (format_comment_or_return_end_line), tp/Texinfo/Convert/TexinfoXML.pm, tp/Texinfo/Convert/DocBook.pm: rename _end_line_or_comment() as format_comment_or_return_end_line().
Date: Sat, 11 Sep 2021 06:37:58 -0400

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 617a2d2  * tp/Texinfo/Convert/Converter.pm 
(format_comment_or_return_end_line), tp/Texinfo/Convert/TexinfoXML.pm, 
tp/Texinfo/Convert/DocBook.pm: rename _end_line_or_comment() as 
format_comment_or_return_end_line().
617a2d2 is described below

commit 617a2d23ce71fc2d7db28684f234c92751124795
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Sep 11 12:37:50 2021 +0200

    * tp/Texinfo/Convert/Converter.pm (format_comment_or_return_end_line),
    tp/Texinfo/Convert/TexinfoXML.pm, tp/Texinfo/Convert/DocBook.pm:
    rename _end_line_or_comment() as format_comment_or_return_end_line().
---
 ChangeLog                        |  6 ++++++
 tp/Texinfo/Convert/Converter.pm  | 10 +++++++++-
 tp/Texinfo/Convert/DocBook.pm    |  2 +-
 tp/Texinfo/Convert/TexinfoXML.pm | 19 ++++++++++---------
 4 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 909d3f6..85862a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2021-09-11  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Convert/Converter.pm (format_comment_or_return_end_line),
+       tp/Texinfo/Convert/TexinfoXML.pm, tp/Texinfo/Convert/DocBook.pm:
+       rename _end_line_or_comment() as format_comment_or_return_end_line().
+
+2021-09-11  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/TexinfoXML.pm
        (_collect_leading_trailing_spaces_arg): move to
        Texinfo::Convert::TexinfoXML as it is only used there.
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index d627521..24817f9 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1080,7 +1080,7 @@ sub float_name_caption($$)
 
 # This is used when the formatted text has no comment nor new line, but
 # one want to add the comment or new line from the original arg
-sub _end_line_or_comment($$)
+sub format_comment_or_return_end_line($$)
 {
   my $self = shift;
   my $element = shift;
@@ -1760,6 +1760,14 @@ This should rarely be used, but the purpose of this 
method is to be able
 to revert a configuration that is always wrong for a given output
 format, like the splitting for example.
 
+=item $end_line = $converter->format_comment_or_return_end_line($element)
+
+Format comment at end of line or return the end of line associated with
+the element.  In many cases, converters ignore comments and output is
+better formatted with new lines added independently of the presence
+of newline or comment in the initial Texinfo line, so most converters
+are better off not using this method.
+
 =item $converter->get_conf($option_string)
 
 Returns the value of the Texinfo configuration option I<$option_string>.
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 52a6b07..7a11d60 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -643,7 +643,7 @@ sub _convert($$;$)
     } elsif ($element->{'type'} and $element->{'type'} eq 
'index_entry_command') {
       my $end_line;
       if ($element->{'args'}->[0]) {
-        $end_line = $self->_end_line_or_comment($element);
+        $end_line = $self->format_comment_or_return_end_line($element);
         if ($self->{'document_context'}->[-1]->{'in_preformatted'}) {
           chomp($end_line);
         }
diff --git a/tp/Texinfo/Convert/TexinfoXML.pm b/tp/Texinfo/Convert/TexinfoXML.pm
index e46fbb6..0e208e8 100644
--- a/tp/Texinfo/Convert/TexinfoXML.pm
+++ b/tp/Texinfo/Convert/TexinfoXML.pm
@@ -590,7 +590,8 @@ sub _leading_spaces_before_argument($)
   }
 }
 
-# return spaces only, end of line is gathered by calling _end_line_or_comment
+# return spaces only, end of line is gathered by calling
+# format_comment_or_return_end_line
 sub _end_line_spaces
 {
   my $element = shift;
@@ -719,7 +720,7 @@ sub _convert_argument_and_end_line($$)
 
   my $converted = $self->convert_tree($element->{'args'}->[-1]);
   $converted .= _end_line_spaces($element);
-  my $end_line = $self->_end_line_or_comment($element);
+  my $end_line = $self->format_comment_or_return_end_line($element);
   return ($converted, $end_line);
 }
 
@@ -890,7 +891,7 @@ sub _convert($$;$)
       push @$attribute, ('index', 
$element->{'extra'}->{'index_entry'}->{'index_name'});
       push @$attribute, _leading_spaces_before_argument($element);
 
-      my $end_line = $self->_end_line_or_comment($element);
+      my $end_line = $self->format_comment_or_return_end_line($element);
 
       return $self->open_element($format_element, ${attribute}).
         $self->_index_entry($element).$self->close_element($format_element)
@@ -970,7 +971,7 @@ sub _convert($$;$)
           if (! $self->get_conf('USE_NODES')) {
             $result .= $self->close_element('node');
           }
-          $result .= $self->_end_line_or_comment($element);
+          $result .= $self->format_comment_or_return_end_line($element);
           pop @{$self->{'document_context'}->[-1]->{'monospace'}};
         } elsif ($Texinfo::Common::root_commands{$cmdname}) {
           my $attribute = [_leading_spaces_before_argument($element)];
@@ -1106,7 +1107,7 @@ sub _convert($$;$)
             $arg_index++;
           }
         }
-        my $end_line = $self->_end_line_or_comment($element);
+        my $end_line = $self->format_comment_or_return_end_line($element);
         # not sure if it may happen
         $end_line = "\n" if ($end_line eq '');
         push @$attribute, $self->_texinfo_line($element);
@@ -1472,7 +1473,7 @@ sub _convert($$;$)
                   $first_proto = 0;
                 }
                 $result .= $self->close_element('columnprototypes');
-                $result .= $self->_end_line_or_comment($element);
+                $result .= $self->format_comment_or_return_end_line($element);
               } elsif ($element->{'extra'}
                          and $element->{'extra'}->{'columnfractions'}) {
                 my $cmd;
@@ -1492,7 +1493,7 @@ sub _convert($$;$)
                              .$self->close_element('columnfraction');
                 }
                 $result .= $self->close_element('columnfractions');
-                $result .= $self->_end_line_or_comment($cmd);
+                $result .= $self->format_comment_or_return_end_line($cmd);
               } else { # bogus multitable
                 $result .= "\n";
               }
@@ -1500,7 +1501,7 @@ sub _convert($$;$)
               # get end of lines from @*table and block @-commands with
               # no argument that have a bogus argument.
               $result .= _end_line_spaces($element);
-              $result .= $self->_end_line_or_comment($element);
+              $result .= $self->format_comment_or_return_end_line($element);
             }
           }
         }
@@ -1655,7 +1656,7 @@ sub _convert($$;$)
       my $end_command = $element->{'extra'}->{'end_command'};
       if ($end_command) {
         $result .= _end_line_spaces($end_command);
-        $result .= $self->_end_line_or_comment($end_command);
+        $result .= $self->format_comment_or_return_end_line($end_command);
       }
     }
     if ($self->{'context_block_commands'}->{$element->{'cmdname'}}) {



reply via email to

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