texinfo-commits
[Top][All Lists]
Advanced

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

[6108] attempted first implementation of new command @U


From: karl
Subject: [6108] attempted first implementation of new command @U
Date: Sun, 08 Feb 2015 22:36:54 +0000

Revision: 6108
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6108
Author:   karl
Date:     2015-02-08 22:36:53 +0000 (Sun, 08 Feb 2015)
Log Message:
-----------
attempted first implementation of new command @U

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Common.pm
    trunk/tp/Texinfo/Convert/Converter.pm
    trunk/tp/Texinfo/Convert/DocBook.pm
    trunk/tp/Texinfo/Convert/HTML.pm
    trunk/tp/Texinfo/Convert/Plaintext.pm
    trunk/tp/Texinfo/Parser.pm
    trunk/util/texinfo.dtd

Property Changed:
----------------
    trunk/tp/Texinfo/Common.pm
    trunk/tp/Texinfo/Convert/Plaintext.pm
    trunk/tp/Texinfo/Parser.pm

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-02-08 17:09:42 UTC (rev 6107)
+++ trunk/ChangeLog     2015-02-08 22:36:53 UTC (rev 6108)
@@ -1,7 +1,22 @@
 2015-02-08  Karl Berry  <address@hidden>
 
+       * tp/Texinfo/Convert/HTML.pm (_convert_U_command): new fn for @U.
+       $default_commands_conversion{'U'}: call it.
+       * tp/Texinfo/Convert/Plaintext.pm (_convert): handle @U, writing
+       binary if output is UTF-8, else just the ASCII string U+xxxx.
+       * tp/Texinfo/Convert/Docbook.pm (_convert): handle @U.
+       * tp/Texinfo/Common.pm (brace_commands) <one_arg_command>: add U.
+       * tp/Texinfo/Parser.pm (simple_text_commands): add U.
+       (debug_hash, debug_list): new fns.
+       * util/texinfo.dtd (U): new ELEMENT.
+
+       * tp/Texinfo/Convert/Converter.pm: move doc about
+       output_internal_links being only for HTML to here.
+
+2015-02-08  Karl Berry  <address@hidden>
+
        * tp/Texinfo/Convert/DocBook.pm: alphabetize, format, debugging;
-       no functional changes.
+       no functional changes intended.
 
 2015-02-07  Gavin Smith  <address@hidden>
 

Modified: trunk/tp/Texinfo/Common.pm
===================================================================
--- trunk/tp/Texinfo/Common.pm  2015-02-08 17:09:42 UTC (rev 6107)
+++ trunk/tp/Texinfo/Common.pm  2015-02-08 22:36:53 UTC (rev 6108)
@@ -1,6 +1,7 @@
+# $Id$
 # Common.pm: definition of commands. Common code of other Texinfo modules.
 #
-# Copyright 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+# Copyright 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -46,6 +47,8 @@
 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
 # will save memory.
 %EXPORT_TAGS = ( 'all' => [ qw(
+debug_hash
+debug_list
 definition_category
 expand_verbatiminclude
 expand_today
@@ -599,9 +602,8 @@
   $style_commands{$command} = 1;
 }
 
-foreach my $one_arg_command (
-  'ctrl','dmn', 'w', 'key',
-  'titlefont','hyphenation','anchor','errormsg') {
+foreach my $one_arg_command ('U', 'ctrl', 'dmn', 'w', 'key',
+    'titlefont', 'hyphenation', 'anchor', 'errormsg') {
   $brace_commands{$one_arg_command} = 1;
 }
 
@@ -615,7 +617,8 @@
 
 # Commands that enclose full texts
 our %context_brace_commands;
-foreach my $context_brace_command ('footnote', 'caption', 'shortcaption', 
'math') {
+foreach my $context_brace_command ('footnote', 'caption',
+    'shortcaption', 'math') {
   $context_brace_commands{$context_brace_command} = $context_brace_command;
   $brace_commands{$context_brace_command} = 1;
 }
@@ -2317,6 +2320,42 @@
   return modify_tree(undef, $tree, \&_move_index_entries_after_items);
 }
 
+sub debug_list
+{
+  my ($label) = shift;
+  my (@list) = (ref $_[0] && $_[0] =~ /.*ARRAY.*/) ? @{$_[0]} : @_;
+
+  my $str = "$label: [";
+  my @items = ();
+  for my $item (@list) {
+    $item = "" if ! defined ($item);
+    $item =~ s/\n/\\n/g;
+    push (@items, $item);
+  }
+  $str .= join (" ", @items);
+  $str .= "]";
+
+  warn "$str\n";
+}
+#
+sub debug_hash
+{
+  my ($label) = shift;
+  my (%hash) = (ref $_[0] && $_[0] =~ /.*HASH.*/) ? %{$_[0]} : @_;
+
+  my $str = "$label: {";
+  my @items = ();
+  for my $key (sort keys %hash) {
+    my $val = $hash{$key} || ""; # no undef
+    $key =~ s/\n/\\n/g;
+    $val =~ s/\n/\\n/g;
+    push (@items, "$key:$val");
+  }
+  $str .= join (",", @items);
+  $str .= "}";
+
+  warn "$str\n";
+}
 1;
 
 __END__
@@ -2625,7 +2664,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2010, 2011, 2012 Free Software Foundation, Inc.
+Copyright 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -2633,4 +2672,3 @@
 or (at your option) any later version.
 
 =cut
-


Property changes on: trunk/tp/Texinfo/Common.pm
___________________________________________________________________
Added: svn:keywords
   + Date Author Id

Modified: trunk/tp/Texinfo/Convert/Converter.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Converter.pm       2015-02-08 17:09:42 UTC (rev 
6107)
+++ trunk/tp/Texinfo/Convert/Converter.pm       2015-02-08 22:36:53 UTC (rev 
6108)
@@ -1,6 +1,7 @@
+# $Id$
 # Converter.pm: Common code for Converters.
 #
-# Copyright 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+# Copyright 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -1713,7 +1714,7 @@
 
 =item %defaults = $converter->converter_defaults($options)
 
-The converter can provide a defaults hash for configurations options.
+The converter can provide a defaults hash for configuration options.
 The I<$options> hash reference holds options for the converter.
 
 =item @global_commands = $converter->converter_global_commands()
@@ -1763,7 +1764,7 @@
 I<$accent_command> is an accent command, which may have other accent
 commands nested.  The function returns the accents formatted either
 as encoded letters, or formatted using I<\&format_accents>.
-If I<$in_upper_case> is set, the result should be upper cased.  
+If I<$in_upper_case> is set, the result should be uppercased.
 
 =back
 
@@ -1786,8 +1787,8 @@
 an argument.  I<$in_upper_case> is optional, and, if set, the text is put
 in upper case.  The function returns the accented letter as XML entity 
 if possible.  I<$use_numeric_entities> is also optional, and, if set, and
-there is no XML entity, the numerical entity corresponding to unicode 
-points is preferred to an ascii transliteration.
+there is no XML entity, the numerical entity corresponding to Unicode 
+points is preferred to an ASCII transliteration.
 
 =item $result = $converter->xml_accents($accent_command, $in_upper_case)
 
@@ -1797,6 +1798,16 @@
 
 =back
 
+Finally, there is:
+
+=item $result = $converter->output_internal_links()
+
+At this level, the method just returns undef.  It is used in the HTML
+output, following the C<--internal-links> option of texi2any/makeinfo
+specification.
+
+=back
+
 =head1 SEE ALSO
 
 L<Texinfo::Common>, L<Texinfo::Convert::Unicode>, L<Texinfo::Report> 
@@ -1808,7 +1819,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc.
+Copyright 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by

Modified: trunk/tp/Texinfo/Convert/DocBook.pm
===================================================================
--- trunk/tp/Texinfo/Convert/DocBook.pm 2015-02-08 17:09:42 UTC (rev 6107)
+++ trunk/tp/Texinfo/Convert/DocBook.pm 2015-02-08 22:36:53 UTC (rev 6108)
@@ -54,7 +54,7 @@
 @EXPORT = qw(
 );
 
-$VERSION = '5.1.91';
+$VERSION = '5.1.90';
 
 my $nbsp = '&#'.hex('00A0').';';
 my $mdash = '&#'.hex('2014').';';
@@ -584,7 +584,7 @@
                      or $root->{'cmdname'} eq 'tab')
                     and $root->{'parent'}->{'type'}
                     and $root->{'parent'}->{'type'} eq 'row') {
-          print STDERR "BUG: multitable cell command not in a row "
+          warn "BUG: multitable cell command not in a row "
             .Texinfo::Parser::_print_current($root);
         }
         
@@ -753,7 +753,8 @@
       #debug_list (" brace command with args", $root->{'args'});
       if ($style_commands_formatting{$root->{'cmdname'}}) {
         if ($Texinfo::Common::context_brace_commands{$root->{'cmdname'}}) {
-          push @{$self->{'document_context'}}, {'monospace' => [0], 
'upper_case' => [0]};
+          push (@{$self->{'document_context'}},
+                {'monospace' => [0], 'upper_case' => [0]});
         }
         my $formatting = $style_commands_formatting{$root->{'cmdname'}};
 
@@ -1002,6 +1003,7 @@
         } else {
           return '';
         }
+
       } elsif ($root->{'cmdname'} eq 'uref' or $root->{'cmdname'} eq 'url') {
         if ($root->{'extra'} and $root->{'extra'}->{'brace_command_contents'}) 
{
           my ($url_text, $url_content);
@@ -1034,6 +1036,7 @@
           # DocBook 5
           # return "<link xl:href=\"$url_text\">$replacement</link>";
         }
+
       } elsif ($root->{'cmdname'} eq 'abbr' or $root->{'cmdname'} eq 
'acronym') {
         my $argument;
         if (scalar (@{$root->{'extra'}->{'brace_command_contents'}}) >= 1
@@ -1050,7 +1053,7 @@
             $argument = "<$element>$arg</$element>";
           }
         }
-        
+        #
         if (scalar (@{$root->{'extra'}->{'brace_command_contents'}}) == 2
            and defined($root->{'extra'}->{'brace_command_contents'}->[-1])) {
           if (defined($argument)) {
@@ -1069,6 +1072,19 @@
         } else {
           return '';
         }
+
+      } elsif ($root->{'cmdname'} eq 'U') {
+        my $argument = $root->{'extra'}->{'brace_command_contents'}->[0]
+                       ->[0]->{'text'};
+        if (defined($argument) && $argument) {
+          $result = "&#x$argument;";
+        } else {
+          $self->line_warn($self->__("no argument specified for 
address@hidden"),
+                           $root->{'line_nr'});
+          $result = '';
+        }
+        return $result;
+
       } elsif ($Texinfo::Common::inline_commands{$root->{'cmdname'}}) {
         my $expand = 0;
         if ($Texinfo::Common::inline_format_commands{$root->{'cmdname'}}) {
@@ -1451,7 +1467,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2015 Free Software Foundation, Inc.
+Copyright 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by

Modified: trunk/tp/Texinfo/Convert/HTML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/HTML.pm    2015-02-08 17:09:42 UTC (rev 6107)
+++ trunk/tp/Texinfo/Convert/HTML.pm    2015-02-08 22:36:53 UTC (rev 6108)
@@ -1831,9 +1831,36 @@
   }
   return &{$self->{'format_heading_text'}}($self, 'titlefont', $text, 0, 
$command);
 }
-
 $default_commands_conversion{'titlefont'} = \&_convert_titlefont_command;
 
+sub _convert_U_command($$$$)
+{
+  my $self = shift;
+  my $cmdname = shift;
+  my $command = shift;
+  my $args = shift;
+  my $res;
+
+  my $text = $args->[0]->{'normal'};
+  # these tests should be in the parser; duplicated in Plaintext.pm
+  if (!defined($text) || !$text) {
+    $self->line_warn($self->__("no argument specified for address@hidden"),
+                     $command->{'line_nr'});
+    $res = '';
+
+  } elsif ($text !~ /^[0-9A-Fa-f]+$/) {
+    $self->line_error(
+      sprintf($self->__("non-hex digits in argument for address@hidden: %s"), 
$text),
+      $command->{'line_nr'});
+    $res = '';
+
+  } else {
+    $res = "&#x$text;"; # ok
+  }
+  return $res;
+}
+$default_commands_conversion{'U'} = \&_convert_U_command;
+
 sub _default_comment($$) {
   my $self = shift;
   my $text = shift;
@@ -7690,7 +7717,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2012 Free Software Foundation, Inc.
+Copyright 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by

Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm       2015-02-08 17:09:42 UTC (rev 
6107)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm       2015-02-08 22:36:53 UTC (rev 
6108)
@@ -1,6 +1,7 @@
+# $Id$
 # Plaintext.pm: output tree as text with filling.
 #
-# Copyright 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+# Copyright 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -261,7 +262,7 @@
   $style_map{$command} = [$style_map{$command}, $style_map{$command}];
 }
 
-# math  is special
+# math is special
 my @asis_commands = ('asis', 'w', 'b', 'ctrl', 'i', 'sc', 't', 'r',
   'slanted', 'sansserif', 'var', 'verb', 'clicksequence',
   'headitemfont', 'dmn');
@@ -2185,6 +2186,32 @@
       $self->_add_text_count($result);
       $self->_add_lines_count(2);
       return $result;
+
+    } elsif ($command eq 'U') {
+      my $arg = $root->{'extra'}->{'brace_command_contents'}
+                ->[0]->[0]->{'text'};
+      my $res;
+      # these tests should be in the parser; duplicated in HTML.pm
+      if (!defined($arg) || !$arg) {
+        $self->line_warn($self->__("no argument specified for address@hidden"),
+                         $root->{'line_nr'});
+        $res = '';
+
+      } elsif ($arg !~ /^[0-9A-Fa-f]+$/) {
+        $self->line_error(
+          sprintf($self->__("non-hex digits in argument for address@hidden: 
%s"), $arg),
+          $root->{'line_nr'});
+        $res = '';
+
+      } else {
+        # binary if utf-8 being output, else ascii.
+        $res = $self->{'to_utf8'} ? chr(hex($arg)) : "U+$arg";
+      }
+
+      $result .= $self->_count_added($formatter->{'container'}, 
+                 $formatter->{'container'}->add_text($res, $res)); 
+      return $result;
+
     } elsif ($command eq 'value') {
       my $expansion = $self->gdt('@{No value for `{value}\'@}', 
                                     {'value' => $root->{'type'}});
@@ -3313,7 +3340,7 @@
 
 =item $converter = Texinfo::Convert::Plaintext->converter($options)
 
-Initialize an Plaintext converter.  
+Initialize a Plaintext converter.  
 
 The I<$options> hash reference holds options for the converter.  In
 this option hash reference a parser object may be associated with the 
@@ -3336,15 +3363,9 @@
 =item $result = $converter->convert_tree($tree)
 
 Convert a Texinfo tree portion I<$tree> and return the resulting 
-output.  This function do not try to output a full document but only
-portions of document.  For a full document use C<convert>.
+output.  This function does not try to output a full document but only
+portions.  For a full document use C<convert>.
 
-=item $result = $converter->output_internal_links()
-
-Returns text representing the links in the document.  At present the format 
-should follow the C<--internal-links> option of texi2any/makeinfo specification
-and this is only relevant for HTML.
-
 =back
 
 =head1 AUTHOR
@@ -3353,7 +3374,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2012 Free Software Foundation, Inc.
+Copyright 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by


Property changes on: trunk/tp/Texinfo/Convert/Plaintext.pm
___________________________________________________________________
Added: svn:keywords
   + Date Author Id

Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm  2015-02-08 17:09:42 UTC (rev 6107)
+++ trunk/tp/Texinfo/Parser.pm  2015-02-08 22:36:53 UTC (rev 6108)
@@ -1,3 +1,4 @@
+# $Id$
 # Parser.pm: parse texinfo code into a tree.
 #
 # Copyright 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
@@ -436,10 +437,10 @@
 
 delete $simple_text_commands{'center'};
 delete $simple_text_commands{'exdent'};
-foreach my $command ('titlefont', 'anchor', 'xref','ref','pxref', 
+foreach my $command ('titlefont', 'anchor', 'xref','ref', 'pxref', 
                      'inforef', 'shortcaption', 'math', 'indicateurl',
                      'email', 'uref', 'url', 'image', 'abbr', 'acronym', 
-                     'dmn', 'ctrl', 'errormsg') {
+                     'dmn', 'ctrl', 'errormsg', 'U') {
   $simple_text_commands{$command} = 1;
 }
 


Property changes on: trunk/tp/Texinfo/Parser.pm
___________________________________________________________________
Added: svn:keywords
   + Date Author Id

Modified: trunk/util/texinfo.dtd
===================================================================
--- trunk/util/texinfo.dtd      2015-02-08 17:09:42 UTC (rev 6107)
+++ trunk/util/texinfo.dtd      2015-02-08 22:36:53 UTC (rev 6108)
@@ -2,7 +2,7 @@
   Document Type Definition for Texinfo XML output (the '-'-xml option).
 
   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-  2011, 2012, 2013 Free Software Foundation, Inc.
+  2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 
   Copying and distribution of this file, with or without modification,
   are permitted in any medium without royalty provided the copyright
@@ -1223,26 +1223,31 @@
           %lineattr;
           value     NMTOKEN #REQUIRED>
 
-<!-- misc -->
+<!-- unusual insertions and other -->
 
-<!ELEMENT bye EMPTY>
-
-<!-- space and accent commands -->
-<!ELEMENT spacecmd EMPTY>
-<!ATTLIST spacecmd
-          type (%spacetype;) #IMPLIED>
 <!ELEMENT accent (#PCDATA | accent | dotless)*>
 <!ATTLIST accent
           %bracketedattr;
           %spacesattr;
           type        CDATA #REQUIRED>
-<!ELEMENT dotless (#PCDATA)>
+
+<!ELEMENT bye EMPTY>
+
 <!ELEMENT click  EMPTY>
 <!ATTLIST click
           command        CDATA #REQUIRED>
+
+<!ELEMENT dotless (#PCDATA)>
+
+<!ELEMENT spacecmd EMPTY>
+<!ATTLIST spacecmd
+          type (%spacetype;) #IMPLIED>
+
 <!ELEMENT today EMPTY>
 
+<!ELEMENT U (#PCDATA)>
 
+
 <!-- emacs-page
      Punctuation and special symbols.  -->
 
@@ -1405,4 +1410,4 @@
 
 <!ENTITY macr "&#xaf;">
 
-<!ENTITY backslash  "\">
+<!ENTITY backslash "\">




reply via email to

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