[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Parser.pm Texinfo/Convert/No...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Parser.pm Texinfo/Convert/No... |
Date: |
Sat, 13 Nov 2010 19:58:28 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 10/11/13 19:58:28
Modified files:
tp/Texinfo : Parser.pm
tp/Texinfo/Convert: NodeNameNormalization.pm Plaintext.pm
Texinfo.pm Text.pm
tp/t : test_utils.pl
Added files:
tp/Texinfo : Common.pm
Removed files:
tp/Texinfo : Commands.pm
Log message:
Rename Texinfo::Commands as Texinfo::Common.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.148&r2=1.149
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Commands.pm?cvsroot=texinfo&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/NodeNameNormalization.pm?cvsroot=texinfo&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Texinfo.pm?cvsroot=texinfo&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/test_utils.pl?cvsroot=texinfo&r1=1.49&r2=1.50
Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -b -r1.148 -r1.149
--- Texinfo/Parser.pm 12 Nov 2010 01:10:43 -0000 1.148
+++ Texinfo/Parser.pm 13 Nov 2010 19:58:28 -0000 1.149
@@ -36,7 +36,7 @@
use Encode;
# commands definitions
-use Texinfo::Commands;
+use Texinfo::Common;
# to expand file names in @include
use Texinfo::Convert::Text;
# to normalize node name, anchor, float arg, listoffloats and first *ref
argument.
@@ -176,24 +176,24 @@
# fh filehandle for the file
-my %no_brace_commands = %Texinfo::Commands::no_brace_commands;
-my %misc_commands = %Texinfo::Commands::misc_commands;
-my %brace_commands = %Texinfo::Commands::brace_commands;
-my %accent_commands = %Texinfo::Commands::accent_commands;
-my %context_brace_commands = %Texinfo::Commands::context_brace_commands;
-my %block_commands = %Texinfo::Commands::block_commands;
-my %block_item_commands = %Texinfo::Commands::block_item_commands;
-my %close_paragraph_commands = %Texinfo::Commands::close_paragraph_commands;
-my %def_map = %Texinfo::Commands::def_map;
-my %def_commands = %Texinfo::Commands::def_commands;
-my %def_aliases = %Texinfo::Commands::def_aliases;
-my %menu_commands = %Texinfo::Commands::menu_commands;
-my %preformatted_commands = %Texinfo::Commands::preformatted_commands;
-my %item_container_commands = %Texinfo::Commands::item_container_commands;
-my %item_line_commands = %Texinfo::Commands::item_line_commands;
-my %deprecated_commands = %Texinfo::Commands::deprecated_commands;
-my %root_commands = %Texinfo::Commands::root_commands;
-my @out_formats = @Texinfo::Commands::out_formats;
+my %no_brace_commands = %Texinfo::Common::no_brace_commands;
+my %misc_commands = %Texinfo::Common::misc_commands;
+my %brace_commands = %Texinfo::Common::brace_commands;
+my %accent_commands = %Texinfo::Common::accent_commands;
+my %context_brace_commands = %Texinfo::Common::context_brace_commands;
+my %block_commands = %Texinfo::Common::block_commands;
+my %block_item_commands = %Texinfo::Common::block_item_commands;
+my %close_paragraph_commands = %Texinfo::Common::close_paragraph_commands;
+my %def_map = %Texinfo::Common::def_map;
+my %def_commands = %Texinfo::Common::def_commands;
+my %def_aliases = %Texinfo::Common::def_aliases;
+my %menu_commands = %Texinfo::Common::menu_commands;
+my %preformatted_commands = %Texinfo::Common::preformatted_commands;
+my %item_container_commands = %Texinfo::Common::item_container_commands;
+my %item_line_commands = %Texinfo::Common::item_line_commands;
+my %deprecated_commands = %Texinfo::Common::deprecated_commands;
+my %root_commands = %Texinfo::Common::root_commands;
+my @out_formats = @Texinfo::Common::out_formats;
# the type of index, f: function, v: variable, t: type
@@ -1812,8 +1812,8 @@
_line_warn($self, sprintf($self->__("unrecognized encoding name
`%s'"),
$text), $line_nr);
} else {
- $encoding = $Texinfo::Commands::encoding_aliases{$encoding}
- if ($Texinfo::Commands::encoding_aliases{$encoding});
+ $encoding = $Texinfo::Common::encoding_aliases{$encoding}
+ if ($Texinfo::Common::encoding_aliases{$encoding});
$self->{'encoding'} = $encoding;
print STDERR "Using encoding $encoding\n" if ($self->{'debug'});
foreach my $input (@{$self->{'input'}}) {
Index: Texinfo/Convert/NodeNameNormalization.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/NodeNameNormalization.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Texinfo/Convert/NodeNameNormalization.pm 6 Nov 2010 12:34:59 -0000
1.4
+++ Texinfo/Convert/NodeNameNormalization.pm 13 Nov 2010 19:58:28 -0000
1.5
@@ -27,7 +27,7 @@
use Unicode::Normalize;
# for the accents definition
-use Texinfo::Commands;
+use Texinfo::Common;
# reuse some conversion hashes
use Texinfo::Convert::Text;
# use the hashes and functions
@@ -66,7 +66,7 @@
= %Texinfo::Convert::Text::text_no_brace_commands;
$normalize_node_no_brace_commands{'*'} = ' ';
-my %accent_commands = %Texinfo::Commands::accent_commands;
+my %accent_commands = %Texinfo::Common::accent_commands;
my %ignored_brace_commands;
foreach my $ignored_brace_command ('xref','ref','pxref','inforef','anchor',
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Texinfo/Convert/Plaintext.pm 12 Nov 2010 01:10:43 -0000 1.1
+++ Texinfo/Convert/Plaintext.pm 13 Nov 2010 19:58:28 -0000 1.2
@@ -22,7 +22,7 @@
use 5.00405;
use strict;
-use Texinfo::Commands;
+use Texinfo::Common;
use Texinfo::Convert::Texinfo;
use Texinfo::Convert::Text;
use Texinfo::Convert::Paragraph;
@@ -66,9 +66,9 @@
}
my %text_no_brace_commands = %Texinfo::Convert::Text::text_no_brace_commands;
my %text_brace_no_arg_commands =
%Texinfo::Convert::Text::text_brace_no_arg_commands;
-my %accent_commands = %Texinfo::Commands::accent_commands;
-my %misc_commands = %Texinfo::Commands::misc_commands;
-my %sectioning_commands = %Texinfo::Commands::sectioning_commands;
+my %accent_commands = %Texinfo::Common::accent_commands;
+my %misc_commands = %Texinfo::Common::misc_commands;
+my %sectioning_commands = %Texinfo::Common::sectioning_commands;
my %ignored_misc_commands;
foreach my $misc_command (keys(%misc_commands)) {
@@ -221,6 +221,18 @@
}
}
+sub convert_line($$)
+{
+ my $self = shift;
+ my $converted = shift;
+ my $line = Texinfo::Convert::Line->new($self->{'paragraph_conf'});
+ push @{$self->{'containers'}}, $line;
+ my $result = $self->convert($converted);
+ $result .= $line->end();
+ pop @{$self->{'containers'}};
+ return $result;
+}
+
# code
# sp
# var, sc -> 'upper_case'
@@ -282,7 +294,13 @@
my $paragraph;
my $line;
if (defined($root->{'text'})) {
+ # ignore text outside of any format.
+ if (ref($self->{'containers'}->[-1])) {
$result .= $self->{'containers'}->[-1]->add_text($root->{'text'});
+ # Warn if ignored text not empty
+ } elsif ($root->{'text'} =~ /\S/) {
+ warn "BUG: ignored text not empty `$root->{'text'}'\n";
+ }
}
if ($root->{'cmdname'}) {
my $command = $root->{'cmdname'};
@@ -349,6 +367,7 @@
my $quotation_arg = Texinfo::Convert::Texinfo::convert(
{'contents' =>
$root->{'extra'}->{'block_command_line_contents'}->[0]});
my $prepended = Texinfo::Parser::parse_texi_line (undef,
'@b{'.${quotation_arg}.':} ');
+ $result = $self->convert_line($prepended);
#return gdt('@b{{quotation_arg}:} ', {'quotation_arg' => $text},
{'keep_texi' => 1});
#$result = convert($root->{'args'}->[0]) ."\n";
}
@@ -360,13 +379,8 @@
or $root->{'cmdname'} eq 'item' or $root->{'cmdname'} eq
'itemx') {
# FIXME handle sectioning commands with their underline
# and item with their prepending
- $line = Texinfo::Convert::Line->new($self->{'paragraph_conf'});
- push @{$self->{'containers'}}, $line;
- $result = $self->convert($root->{'args'}->[0]);
- $result .= $line->end();
- pop @{$self->{'containers'}};
+ $result = $self->convert_line($root->{'args'}->[0]);
chomp ($result);
-
$result .= "\n";
} elsif ($root->{'cmdname'} eq 'sp') {
if ($root->{'extra'}->{'misc_args'}->[0]) {
@@ -393,6 +407,9 @@
}
if ($root->{'type'} and $root->{'type'} eq 'def_line') {
#print STDERR "$root->{'extra'}->{'def_command'}\n";
+ foreach my $parsed_arg (@{$root->{'extra'}->{'def_args'}}) {
+
+ }
$result = $self->convert($root->{'args'}->[0]) if ($root->{'args'});
} elsif ($root->{'type'} and $root->{'type'} eq 'menu_entry') {
foreach my $arg (@{$root->{'args'}}) {
Index: Texinfo/Convert/Texinfo.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Texinfo.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Texinfo/Convert/Texinfo.pm 6 Nov 2010 00:41:28 -0000 1.1
+++ Texinfo/Convert/Texinfo.pm 13 Nov 2010 19:58:28 -0000 1.2
@@ -24,7 +24,7 @@
use strict;
# commands definitions
-use Texinfo::Commands;
+use Texinfo::Common;
require Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -34,10 +34,10 @@
$VERSION = '0.01';
-my %misc_commands = %Texinfo::Commands::misc_commands;
-my %brace_commands = %Texinfo::Commands::brace_commands;
-my %block_commands = %Texinfo::Commands::block_commands;
-my %def_commands = %Texinfo::Commands::def_commands;
+my %misc_commands = %Texinfo::Common::misc_commands;
+my %brace_commands = %Texinfo::Common::brace_commands;
+my %block_commands = %Texinfo::Common::block_commands;
+my %def_commands = %Texinfo::Common::def_commands;
sub convert ($);
# Following subroutines deal with transforming a texinfo tree into texinfo
Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- Texinfo/Convert/Text.pm 12 Nov 2010 01:10:43 -0000 1.18
+++ Texinfo/Convert/Text.pm 13 Nov 2010 19:58:28 -0000 1.19
@@ -23,7 +23,7 @@
use strict;
# accent commands list.
-use Texinfo::Commands;
+use Texinfo::Common;
use Data::Dumper;
require Exporter;
@@ -145,7 +145,7 @@
'{', '{',
);
-my %accent_commands = %Texinfo::Commands::accent_commands;
+my %accent_commands = %Texinfo::Common::accent_commands;
my %unicode_to_eight_bit = (
'iso8859_1' => {
@@ -668,7 +668,7 @@
}
my $encoding_map_name
- = $Texinfo::Commands::eight_bit_encoding_aliases{$encoding};
+ = $Texinfo::Common::eight_bit_encoding_aliases{$encoding};
# At this point we have the utf8 encoded results for the accent
# commands stack, with all the intermediate results.
# For each one we'll check if it is possible to encode it in the
@@ -784,7 +784,7 @@
# $accent, \&ascii_accent);
return unicode_accents($accent, \&ascii_accent);
} elsif ($encoding
- and $Texinfo::Commands::eight_bit_encoding_aliases{$encoding}) {
+ and $Texinfo::Common::eight_bit_encoding_aliases{$encoding}) {
return eight_bit_accents($accent, $encoding, \&ascii_accent);
} else {
#return ascii_accent(convert($accent->{'args'}->[0], $options), $accent);
Index: t/test_utils.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/test_utils.pl,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- t/test_utils.pl 12 Nov 2010 01:10:43 -0000 1.49
+++ t/test_utils.pl 13 Nov 2010 19:58:28 -0000 1.50
@@ -34,6 +34,10 @@
our $arg_test_case = shift @ARGV;
+my %formats = (
+ 'plaintext' => \&convert_to_plaintext,
+);
+
#my $remove_parent = sub {my $h = shift; delete $h->{'parent'}};
#my $transformer = Data::Transformer->new('hash'=>$remove_parent);
sub remove_keys($$;$);
@@ -166,10 +170,6 @@
return $converter->convert($tree);
}
-my %formats = (
- 'plaintext' => \&convert_to_plaintext,
-);
-
sub test($$)
{
my $self = shift;
@@ -226,8 +226,10 @@
my %converted;
foreach my $format (@tested_formats) {
- # $converted{$format} = &{$formats{$format}}($self, $result);
- # print STDERR "$format: \n$converted{$format}";
+ if (defined($formats{$format})) {
+ $converted{$format} = &{$formats{$format}}($self, $result);
+ print STDERR "$format: \n$converted{$format}";
+ }
}
my $file = "t/results/$self->{'name'}/$test_name.pl";
Index: Texinfo/Common.pm
===================================================================
RCS file: Texinfo/Common.pm
diff -N Texinfo/Common.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Texinfo/Common.pm 13 Nov 2010 19:58:28 -0000 1.1
@@ -0,0 +1,419 @@
+# Common.pm: definition of commands. Common code of other Texinfo modules.
+#
+# Copyright 2010 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
+# the Free Software Foundation; either version 3 of the License,
+# or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Original author: Patrice Dumas <address@hidden>
+# Parts (also from Patrice Dumas) come from texi2html.pl or texi2html.init.
+
+package Texinfo::Common;
+
+use strict;
+
+# nothing exported.
+require Exporter;
+use vars qw($VERSION);
+$VERSION = '0.01';
+
+# i18n
+sub N__($)
+{
+ return $_[0];
+}
+
+our %no_brace_commands; # commands never taking braces
+
+foreach my $no_brace_command ('*',' ',"\t","\n",'-', '|', '/',':','!',
+ '?','.','@','}','{','\\') {
+ $no_brace_commands{$no_brace_command} = 1;
+}
+
+# commands taking a line as argument or no argument.
+# sectioning commands and def* commands are added below.
+# index commands are added dynamically.
+#
+# The values signification is:
+# special: no value and macro expansion, all the line is used, and
+# analysed during parsing (_parse_special_misc_command)
+# lineraw: no value and macro expansion, the line is kept as-is, not
+# analysed
+# skipline: no argument, everything else on the line is skipped
+# skipspace: no argument, following spaces are skipped.
+# noarg: no argument
+# text: the line is parsed as texinfo, and the argument is converted
+# to simple text (in _end_line)
+# line: the line is parsed as texinfo
+# a number: the line is parsed as texinfo and the result should be plain
+# text maybe followed by a comment; the result is analysed
+# during parsing (_parse_line_command_args).
+# The number is an indication of the number of arguments of
+# the command.
+#
+# Beware that @item and @itemx may be like 'line' or 'skipspace' depending
+# on the context.
+our %misc_commands = (
+ 'node' => 'line', # special arg
+ 'bye' => 'skipline', # no arg
+ # set, clear
+ 'set' => 'special', # special arg
+ 'clear' => 'special', # special arg
+ 'unmacro' => 'special',
+ # comments
+ 'comment' => 'lineraw',
+ 'c' => 'lineraw',
+ # special
+ 'definfoenclose' => 5,
+ 'alias' => 3,
+ # number of arguments is not known in advance.
+ 'columnfractions' => 1,
+ # file names
+ 'setfilename' => 'text',
+ 'verbatiminclude' => 'text',
+ 'include' => 'text',
+
+ 'raisesections' => 'skipline', # no arg
+ 'lowersections' => 'skipline', # no arg
+ 'contents' => 'skipline', # no arg
+ 'shortcontents' => 'skipline', # no arg
+ 'summarycontents' => 'skipline', # no arg
+ 'insertcopying' => 'noarg', # no arg
+ 'clickstyle' => 'special', # arg should be an @-command
+ # more relevant in preamble
+ 'setcontentsaftertitlepage' => 'skipline', # no arg
+ 'setshortcontentsaftertitlepage' => 'skipline', # no arg
+ 'documentencoding' => 'text', # or 1?
+ 'novalidate' => 'skipline', # no arg
+ 'dircategory' => 'text', # line. Position with regard
+ # with direntry is significant
+ 'pagesizes' => 'line', # can have 2 args
+ # or one? 200mm,150mm 11.5in
+ 'finalout' => 'skipline', # no arg
+ 'paragraphindent' => 1, # arg none asis
+ # or a number and forbids anything else on the line
+ 'firstparagraphindent' => 1, # none insert
+ 'frenchspacing' => 1, # on off
+ 'fonttextsize' => 1, # 10 11
+ 'allowcodebreaks' => 1, # false or true
+ 'exampleindent' => 1, # asis or a number
+ 'footnotestyle' => 1, # end and separate, nothing else on the line
+ 'afourpaper' => 'skipline', # no arg
+ 'afivepaper' => 'skipline', # no arg
+ 'afourlatex' => 'skipline', # no arg
+ 'afourwide' => 'skipline', # no arg
+ 'headings' => 1, #off on single double singleafter doubleafter
+ # interacts with setchapternewpage
+ 'setchapternewpage' => 1, # off on odd
+
+ # only relevant in TeX, and special
+ 'everyheading' => 'lineraw', # @*heading @*footing use @|
+ 'everyfooting' => 'lineraw', # + @thispage @thissectionname
+ 'evenheading' => 'lineraw', # @thissectionnum @thissection
+ 'evenfooting' => 'lineraw', # @thischaptername @thischapternum
+ 'oddheading' => 'lineraw', # @thischapter @thistitle @thisfile
+ 'oddfooting' => 'lineraw',
+
+ 'smallbook' => 'skipline', # no arg
+ 'syncodeindex' => 2, # args are index identifiers
+ 'synindex' => 2,
+ 'defindex' => 1, # one identifier arg
+ 'defcodeindex' => 1, # one identifier arg
+ 'documentlanguage' => 'text', # language code arg
+ 'kbdinputstyle' => 1, # code example distinct
+ 'everyheadingmarks' => 1, # top bottom
+ 'everyfootingmarks' => 1,
+ 'evenheadingmarks' => 1,
+ 'oddheadingmarks' => 1,
+ 'evenfootingmarks' => 1,
+ 'oddfootingmarks' => 1,
+ # not valid for info (should be in @iftex)
+ 'cropmarks' => 'skipline', # no arg
+
+ # formatting
+ 'center' => 'line',
+ 'printindex' => 1,
+ 'listoffloats' => 'line',
+ # especially in titlepage
+ 'shorttitle' => 'line',
+ 'shorttitlepage' => 'line',
+ 'settitle' => 'line',
+ 'author' => 'line',
+ 'subtitle' => 'line',
+ 'title' => 'line',
+ 'sp' => 1, # numerical arg
+ 'page' => 'skipline', # no arg (pagebreak)
+ 'need' => 1, # one numerical/real arg
+ # formatting
+ 'noindent' => 'skipspace', # no arg
+ 'indent' => 'skipspace',
+ 'exdent' => 'line',
+ 'headitem' => 'skipspace',
+ 'item' => 'skipspace', # or line, depending on the context
+ 'itemx' => 'skipspace',
+ 'tab' => 'skipspace',
+ # not valid for info (should be in @iftex)
+ 'vskip' => 'lineraw', # arg line in TeX
+ # obsolete @-commands.
+ 'refill' => 'noarg', # no arg (obsolete, to be ignored)
+ # Remove spaces and end of lines after the
+ # commands? If no, they can lead to empty lines
+ 'quote-arg' => 'skipline',
+ 'allow-recursion' => 'skipline',
+);
+
+# command with braces. Value is the max number of arguments.
+our %brace_commands;
+
+
+foreach my $no_arg_command ('TeX','LaTeX','bullet','copyright',
+ 'registeredsymbol','dots','enddots','equiv','error','expansion','arrow',
+ 'minus','point','print','result','today',
+ 'aa','AA','ae','oe','AE','OE','o','O','ss','l','L','DH','dh','TH','th',
+ 'exclamdown','questiondown','pounds','ordf','ordm','comma','euro',
+ 'geq','leq','tie','textdegree','click',
+ 'quotedblleft','quotedblright','quoteleft','quoteright','quotedblbase',
+ 'quotesinglbase','guillemetleft','guillemetright','guillemotleft',
+ 'guillemotright','guilsinglleft','guilsinglright') {
+ $brace_commands{$no_arg_command} = 0;
+}
+
+# accent commands. They may be called with and without braces.
+our %accent_commands;
+foreach my $accent_command ('"','~','^','`',"'",',','=',
+ 'ringaccent','H','dotaccent','u','ubaraccent',
+ 'udotaccent','v','ogonek','tieaccent', 'dotless') {
+ $accent_commands{$accent_command} = 1;
+ $brace_commands{$accent_command} = 1;
+}
+
+foreach my $one_arg_command ('asis','b','cite','clicksequence','code',
+ 'command','ctrl','dfn','dmn','emph','env','file','headitemfont',
+ 'i','slanted','sansserif','kbd','key','option','r','samp','sc','strong',
+ 't','var', 'w', 'verb', 'indicateurl',
+ 'titlefont','hyphenation','anchor') {
+ $brace_commands{$one_arg_command} = 1;
+}
+
+# Commands that enclose full texts
+our %context_brace_commands;
+foreach my $context_brace_command ('footnote', 'caption', 'shortcaption',
'math') {
+ $context_brace_commands{$context_brace_command} = $context_brace_command;
+ $brace_commands{$context_brace_command} = 1;
+}
+
+foreach my $two_arg_command('email','acronym','abbr') {
+ $brace_commands{$two_arg_command} = 2;
+}
+
+foreach my $three_arg_command('uref','url','inforef') {
+ $brace_commands{$three_arg_command} = 3;
+}
+
+foreach my $five_arg_command('xref','ref','pxref','image') {
+ $brace_commands{$five_arg_command} = 5;
+}
+
+
+# commands delimiting blocks, with an @end.
+# Value is either the number of arguments on the line separated by
+# commas or the type of command, 'raw', 'def' or 'multitable'.
+our %block_commands;
+
+# commands that have a possible content before an item
+our %block_item_commands;
+
+# commands that forces closing an opened paragraph.
+our %close_paragraph_commands;
+
+our %def_map = (
+ # basic commands.
+ # 'arg' and 'argtype' are for everything appearing after the other
+ # arguments.
+ 'deffn', [ 'category', 'name', 'arg' ],
+ 'defvr', [ 'category', 'name' ],
+ 'deftypefn', [ 'category', 'type', 'name', 'argtype' ],
+ 'deftypeop', [ 'category', 'class' , 'type', 'name', 'argtype' ],
+ 'deftypevr', [ 'category', 'type', 'name' ],
+ 'defcv', [ 'category', 'class' , 'name' ],
+ 'deftypecv', [ 'category', 'class' , 'type', 'name' ],
+ 'defop', [ 'category', 'class' , 'name', 'arg' ],
+ 'deftp', [ 'category', 'name', 'argtype' ],
+ # shortcuts
+ # FIXME i18n
+ 'defun', {'deffn' => 'Function'},
+ 'defmac', {'deffn' => 'Macro'},
+ 'defspec', {'deffn' => '{Special Form}'},
+ 'defvar', {'defvr' => 'Variable'},
+ 'defopt', {'defvr' => '{User Option}'},
+ 'deftypefun', {'deftypefn' => 'Function'},
+ 'deftypevar', {'deftypevr' => 'Variable'},
+ 'defivar', {'defcv' => '{Instance Variable}'},
+ 'deftypeivar', {'deftypecv' => '{Instance Variable}'},
+ 'defmethod', {'defop' => 'Method'},
+ 'deftypemethod', {'deftypeop' => 'Method'},
+);
+
+our %def_commands;
+our %def_aliases;
+foreach my $def_command(keys %def_map) {
+ $block_commands{$def_command} = 'def';
+ $misc_commands{$def_command.'x'} = 'line';
+ $def_commands{$def_command} = 1;
+ $def_commands{$def_command.'x'} = 1;
+}
+
+#print STDERR "".Data::Dumper->Dump([\%def_aliases]);
+#print STDERR "".Data::Dumper->Dump([\%def_prepended_content]);
+
+$block_commands{'multitable'} = 'multitable';
+$block_item_commands{'multitable'} = 1;
+
+# block commands in which menu entry and menu comments appear
+our %menu_commands;
+foreach my $menu_command ('menu', 'detailmenu', 'direntry') {
+ $menu_commands{$menu_command} = 1;
+ $block_commands{$menu_command} = 0;
+};
+
+foreach my $block_command(
+ 'cartouche', 'group', 'raggedright', 'flushleft', 'flushright',
+ 'titlepage', 'copying', 'documentdescription') {
+ $block_commands{$block_command} = 0;
+}
+
+our %preformatted_commands;
+foreach my $preformatted_command(
+ 'example', 'smallexample', 'display', 'smalldisplay', 'lisp',
+ 'smalllisp', 'format', 'smallformat') {
+ $block_commands{$preformatted_command} = 0;
+ $preformatted_commands{$preformatted_command} = 1;
+}
+
+our @out_formats = ('html', 'tex', 'xml', 'docbook');
+# macro/rmacro are special
+foreach my $raw_command (@out_formats, 'verbatim',
+ 'ignore', 'macro', 'rmacro') {
+ $block_commands{$raw_command} = 'raw';
+}
+
+foreach my $command (@out_formats, 'info', 'plaintext') {
+ $block_commands{'if' . $command} = 'conditional';
+ $block_commands{'ifnot' . $command} = 'conditional';
+}
+
+$block_commands{'ifset'} = 'conditional';
+$block_commands{'ifclear'} = 'conditional';
+
+# 'macro' ?
+foreach my $block_command_one_arg('table', 'ftable', 'vtable',
+ 'itemize', 'enumerate', 'quotation', 'small_quotation') {
+ $block_commands{$block_command_one_arg} = 1;
+ $block_item_commands{$block_command_one_arg} = 1
+ unless ($block_command_one_arg =~ /quotation/);
+}
+
+$block_commands{'float'} = 2;
+
+our %item_container_commands;
+foreach my $item_container_command ('itemize', 'enumerate') {
+ $item_container_commands{$item_container_command} = 1;
+}
+our %item_line_commands;
+foreach my $item_line_command ('table', 'ftable', 'vtable') {
+ $item_line_commands{$item_line_command} = 1;
+}
+
+our %deprecated_commands = (
+ 'ctrl' => '',
+ 'allow-recursion' => N__('recursion is always allowed'),
+ 'quote-arg' => N__('arguments are quoted by default'),
+);
+
+# commands that should only appear at the root level and contain up to
+# the next root command. @node and sectioning commands.
+our %root_commands;
+
+our %sectioning_commands;
+
+foreach my $sectioning_command (
+ 'top',
+ 'chapter',
+ 'unnumbered',
+ 'chapheading',
+ 'appendix',
+ 'section',
+ 'unnumberedsec',
+ 'heading',
+ 'appendixsec',
+ 'subsection',
+ 'unnumberedsubsec',
+ 'subheading',
+ 'appendixsubsec',
+ 'subsubsection',
+ 'unnumberedsubsubsec',
+ 'subsubheading',
+ 'appendixsubsubsec',
+ 'part',
+ 'appendixsection',
+ 'majorheading',
+ 'chapheading',
+ 'centerchap'
+) {
+ $misc_commands{$sectioning_command} = 'line';
+ if ($sectioning_command =~ /heading/) {
+ $close_paragraph_commands{$sectioning_command} = 1;
+ } else {
+ $root_commands{$sectioning_command} = 1;
+ }
+ $sectioning_commands{$sectioning_command} = 1;
+}
+
+$root_commands{'node'} = 1;
+
+
+
+# charset related definitions.
+
+our %perl_charset_to_html = (
+ 'utf8' => 'utf-8',
+ 'utf-8-strict' => 'utf-8',
+ 'ascii' => 'us-ascii',
+ 'shiftjis' => 'shift_jis',
+);
+
+# encoding name normalization to html-compatible encoding names
+our %encoding_aliases = (
+ 'latin1' => 'iso-8859-1',
+);
+
+foreach my $perl_charset (keys(%perl_charset_to_html)) {
+ $encoding_aliases{$perl_charset} = $perl_charset_to_html{$perl_charset};
+ $encoding_aliases{$perl_charset_to_html{$perl_charset}}
+ = $perl_charset_to_html{$perl_charset};
+}
+our %eight_bit_encoding_aliases = (
+ "iso-8859-1", 'iso8859_1',
+ "iso-8859-2", 'iso8859_2',
+ "iso-8859-15", 'iso8859_15',
+ "koi8-r", 'koi8',
+ "koi8-u", 'koi8',
+);
+
+foreach my $encoding (keys(%eight_bit_encoding_aliases)) {
+ $encoding_aliases{$encoding} = $encoding;
+ $encoding_aliases{$eight_bit_encoding_aliases{$encoding}} = $encoding;
+}
+
+
+1;
Index: Texinfo/Commands.pm
===================================================================
RCS file: Texinfo/Commands.pm
diff -N Texinfo/Commands.pm
--- Texinfo/Commands.pm 12 Nov 2010 01:10:43 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,419 +0,0 @@
-# Commands.pm: definition of commands. Common code of other Texinfo modules.
-#
-# Copyright 2010 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
-# the Free Software Foundation; either version 3 of the License,
-# or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# Original author: Patrice Dumas <address@hidden>
-# Parts (also from Patrice Dumas) come from texi2html.pl or texi2html.init.
-
-package Texinfo::Commands;
-
-use strict;
-
-# nothing exported.
-require Exporter;
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-# i18n
-sub N__($)
-{
- return $_[0];
-}
-
-our %no_brace_commands; # commands never taking braces
-
-foreach my $no_brace_command ('*',' ',"\t","\n",'-', '|', '/',':','!',
- '?','.','@','}','{','\\') {
- $no_brace_commands{$no_brace_command} = 1;
-}
-
-# commands taking a line as argument or no argument.
-# sectioning commands and def* commands are added below.
-# index commands are added dynamically.
-#
-# The values signification is:
-# special: no value and macro expansion, all the line is used, and
-# analysed during parsing (_parse_special_misc_command)
-# lineraw: no value and macro expansion, the line is kept as-is, not
-# analysed
-# skipline: no argument, everything else on the line is skipped
-# skipspace: no argument, following spaces are skipped.
-# noarg: no argument
-# text: the line is parsed as texinfo, and the argument is converted
-# to simple text (in _end_line)
-# line: the line is parsed as texinfo
-# a number: the line is parsed as texinfo and the result should be plain
-# text maybe followed by a comment; the result is analysed
-# during parsing (_parse_line_command_args).
-# The number is an indication of the number of arguments of
-# the command.
-#
-# Beware that @item and @itemx may be like 'line' or 'skipspace' depending
-# on the context.
-our %misc_commands = (
- 'node' => 'line', # special arg
- 'bye' => 'skipline', # no arg
- # set, clear
- 'set' => 'special', # special arg
- 'clear' => 'special', # special arg
- 'unmacro' => 'special',
- # comments
- 'comment' => 'lineraw',
- 'c' => 'lineraw',
- # special
- 'definfoenclose' => 5,
- 'alias' => 3,
- # number of arguments is not known in advance.
- 'columnfractions' => 1,
- # file names
- 'setfilename' => 'text',
- 'verbatiminclude' => 'text',
- 'include' => 'text',
-
- 'raisesections' => 'skipline', # no arg
- 'lowersections' => 'skipline', # no arg
- 'contents' => 'skipline', # no arg
- 'shortcontents' => 'skipline', # no arg
- 'summarycontents' => 'skipline', # no arg
- 'insertcopying' => 'noarg', # no arg
- 'clickstyle' => 'special', # arg should be an @-command
- # more relevant in preamble
- 'setcontentsaftertitlepage' => 'skipline', # no arg
- 'setshortcontentsaftertitlepage' => 'skipline', # no arg
- 'documentencoding' => 'text', # or 1?
- 'novalidate' => 'skipline', # no arg
- 'dircategory' => 'text', # line. Position with regard
- # with direntry is significant
- 'pagesizes' => 'line', # can have 2 args
- # or one? 200mm,150mm 11.5in
- 'finalout' => 'skipline', # no arg
- 'paragraphindent' => 1, # arg none asis
- # or a number and forbids anything else on the line
- 'firstparagraphindent' => 1, # none insert
- 'frenchspacing' => 1, # on off
- 'fonttextsize' => 1, # 10 11
- 'allowcodebreaks' => 1, # false or true
- 'exampleindent' => 1, # asis or a number
- 'footnotestyle' => 1, # end and separate, nothing else on the line
- 'afourpaper' => 'skipline', # no arg
- 'afivepaper' => 'skipline', # no arg
- 'afourlatex' => 'skipline', # no arg
- 'afourwide' => 'skipline', # no arg
- 'headings' => 1, #off on single double singleafter doubleafter
- # interacts with setchapternewpage
- 'setchapternewpage' => 1, # off on odd
-
- # only relevant in TeX, and special
- 'everyheading' => 'lineraw', # @*heading @*footing use @|
- 'everyfooting' => 'lineraw', # + @thispage @thissectionname
- 'evenheading' => 'lineraw', # @thissectionnum @thissection
- 'evenfooting' => 'lineraw', # @thischaptername @thischapternum
- 'oddheading' => 'lineraw', # @thischapter @thistitle @thisfile
- 'oddfooting' => 'lineraw',
-
- 'smallbook' => 'skipline', # no arg
- 'syncodeindex' => 2, # args are index identifiers
- 'synindex' => 2,
- 'defindex' => 1, # one identifier arg
- 'defcodeindex' => 1, # one identifier arg
- 'documentlanguage' => 'text', # language code arg
- 'kbdinputstyle' => 1, # code example distinct
- 'everyheadingmarks' => 1, # top bottom
- 'everyfootingmarks' => 1,
- 'evenheadingmarks' => 1,
- 'oddheadingmarks' => 1,
- 'evenfootingmarks' => 1,
- 'oddfootingmarks' => 1,
- # not valid for info (should be in @iftex)
- 'cropmarks' => 'skipline', # no arg
-
- # formatting
- 'center' => 'line',
- 'printindex' => 1,
- 'listoffloats' => 'line',
- # especially in titlepage
- 'shorttitle' => 'line',
- 'shorttitlepage' => 'line',
- 'settitle' => 'line',
- 'author' => 'line',
- 'subtitle' => 'line',
- 'title' => 'line',
- 'sp' => 1, # numerical arg
- 'page' => 'skipline', # no arg (pagebreak)
- 'need' => 1, # one numerical/real arg
- # formatting
- 'noindent' => 'skipspace', # no arg
- 'indent' => 'skipspace',
- 'exdent' => 'line',
- 'headitem' => 'skipspace',
- 'item' => 'skipspace', # or line, depending on the context
- 'itemx' => 'skipspace',
- 'tab' => 'skipspace',
- # not valid for info (should be in @iftex)
- 'vskip' => 'lineraw', # arg line in TeX
- # obsolete @-commands.
- 'refill' => 'noarg', # no arg (obsolete, to be ignored)
- # Remove spaces and end of lines after the
- # commands? If no, they can lead to empty lines
- 'quote-arg' => 'skipline',
- 'allow-recursion' => 'skipline',
-);
-
-# command with braces. Value is the max number of arguments.
-our %brace_commands;
-
-
-foreach my $no_arg_command ('TeX','LaTeX','bullet','copyright',
- 'registeredsymbol','dots','enddots','equiv','error','expansion','arrow',
- 'minus','point','print','result','today',
- 'aa','AA','ae','oe','AE','OE','o','O','ss','l','L','DH','dh','TH','th',
- 'exclamdown','questiondown','pounds','ordf','ordm','comma','euro',
- 'geq','leq','tie','textdegree','click',
- 'quotedblleft','quotedblright','quoteleft','quoteright','quotedblbase',
- 'quotesinglbase','guillemetleft','guillemetright','guillemotleft',
- 'guillemotright','guilsinglleft','guilsinglright') {
- $brace_commands{$no_arg_command} = 0;
-}
-
-# accent commands. They may be called with and without braces.
-our %accent_commands;
-foreach my $accent_command ('"','~','^','`',"'",',','=',
- 'ringaccent','H','dotaccent','u','ubaraccent',
- 'udotaccent','v','ogonek','tieaccent', 'dotless') {
- $accent_commands{$accent_command} = 1;
- $brace_commands{$accent_command} = 1;
-}
-
-foreach my $one_arg_command ('asis','b','cite','clicksequence','code',
- 'command','ctrl','dfn','dmn','emph','env','file','headitemfont',
- 'i','slanted','sansserif','kbd','key','option','r','samp','sc','strong',
- 't','var', 'w', 'verb', 'indicateurl',
- 'titlefont','hyphenation','anchor') {
- $brace_commands{$one_arg_command} = 1;
-}
-
-# Commands that enclose full texts
-our %context_brace_commands;
-foreach my $context_brace_command ('footnote', 'caption', 'shortcaption',
'math') {
- $context_brace_commands{$context_brace_command} = $context_brace_command;
- $brace_commands{$context_brace_command} = 1;
-}
-
-foreach my $two_arg_command('email','acronym','abbr') {
- $brace_commands{$two_arg_command} = 2;
-}
-
-foreach my $three_arg_command('uref','url','inforef') {
- $brace_commands{$three_arg_command} = 3;
-}
-
-foreach my $five_arg_command('xref','ref','pxref','image') {
- $brace_commands{$five_arg_command} = 5;
-}
-
-
-# commands delimiting blocks, with an @end.
-# Value is either the number of arguments on the line separated by
-# commas or the type of command, 'raw', 'def' or 'multitable'.
-our %block_commands;
-
-# commands that have a possible content before an item
-our %block_item_commands;
-
-# commands that forces closing an opened paragraph.
-our %close_paragraph_commands;
-
-our %def_map = (
- # basic commands.
- # 'arg' and 'argtype' are for everything appearing after the other
- # arguments.
- 'deffn', [ 'category', 'name', 'arg' ],
- 'defvr', [ 'category', 'name' ],
- 'deftypefn', [ 'category', 'type', 'name', 'argtype' ],
- 'deftypeop', [ 'category', 'class' , 'type', 'name', 'argtype' ],
- 'deftypevr', [ 'category', 'type', 'name' ],
- 'defcv', [ 'category', 'class' , 'name' ],
- 'deftypecv', [ 'category', 'class' , 'type', 'name' ],
- 'defop', [ 'category', 'class' , 'name', 'arg' ],
- 'deftp', [ 'category', 'name', 'argtype' ],
- # shortcuts
- # FIXME i18n
- 'defun', {'deffn' => 'Function'},
- 'defmac', {'deffn' => 'Macro'},
- 'defspec', {'deffn' => '{Special Form}'},
- 'defvar', {'defvr' => 'Variable'},
- 'defopt', {'defvr' => '{User Option}'},
- 'deftypefun', {'deftypefn' => 'Function'},
- 'deftypevar', {'deftypevr' => 'Variable'},
- 'defivar', {'defcv' => '{Instance Variable}'},
- 'deftypeivar', {'deftypecv' => '{Instance Variable}'},
- 'defmethod', {'defop' => 'Method'},
- 'deftypemethod', {'deftypeop' => 'Method'},
-);
-
-our %def_commands;
-our %def_aliases;
-foreach my $def_command(keys %def_map) {
- $block_commands{$def_command} = 'def';
- $misc_commands{$def_command.'x'} = 'line';
- $def_commands{$def_command} = 1;
- $def_commands{$def_command.'x'} = 1;
-}
-
-#print STDERR "".Data::Dumper->Dump([\%def_aliases]);
-#print STDERR "".Data::Dumper->Dump([\%def_prepended_content]);
-
-$block_commands{'multitable'} = 'multitable';
-$block_item_commands{'multitable'} = 1;
-
-# block commands in which menu entry and menu comments appear
-our %menu_commands;
-foreach my $menu_command ('menu', 'detailmenu', 'direntry') {
- $menu_commands{$menu_command} = 1;
- $block_commands{$menu_command} = 0;
-};
-
-foreach my $block_command(
- 'cartouche', 'group', 'raggedright', 'flushleft', 'flushright',
- 'titlepage', 'copying', 'documentdescription') {
- $block_commands{$block_command} = 0;
-}
-
-our %preformatted_commands;
-foreach my $preformatted_command(
- 'example', 'smallexample', 'display', 'smalldisplay', 'lisp',
- 'smalllisp', 'format', 'smallformat') {
- $block_commands{$preformatted_command} = 0;
- $preformatted_commands{$preformatted_command} = 1;
-}
-
-our @out_formats = ('html', 'tex', 'xml', 'docbook');
-# macro/rmacro are special
-foreach my $raw_command (@out_formats, 'verbatim',
- 'ignore', 'macro', 'rmacro') {
- $block_commands{$raw_command} = 'raw';
-}
-
-foreach my $command (@out_formats, 'info', 'plaintext') {
- $block_commands{'if' . $command} = 'conditional';
- $block_commands{'ifnot' . $command} = 'conditional';
-}
-
-$block_commands{'ifset'} = 'conditional';
-$block_commands{'ifclear'} = 'conditional';
-
-# 'macro' ?
-foreach my $block_command_one_arg('table', 'ftable', 'vtable',
- 'itemize', 'enumerate', 'quotation', 'small_quotation') {
- $block_commands{$block_command_one_arg} = 1;
- $block_item_commands{$block_command_one_arg} = 1
- unless ($block_command_one_arg =~ /quotation/);
-}
-
-$block_commands{'float'} = 2;
-
-our %item_container_commands;
-foreach my $item_container_command ('itemize', 'enumerate') {
- $item_container_commands{$item_container_command} = 1;
-}
-our %item_line_commands;
-foreach my $item_line_command ('table', 'ftable', 'vtable') {
- $item_line_commands{$item_line_command} = 1;
-}
-
-our %deprecated_commands = (
- 'ctrl' => '',
- 'allow-recursion' => N__('recursion is always allowed'),
- 'quote-arg' => N__('arguments are quoted by default'),
-);
-
-# commands that should only appear at the root level and contain up to
-# the next root command. @node and sectioning commands.
-our %root_commands;
-
-our %sectioning_commands;
-
-foreach my $sectioning_command (
- 'top',
- 'chapter',
- 'unnumbered',
- 'chapheading',
- 'appendix',
- 'section',
- 'unnumberedsec',
- 'heading',
- 'appendixsec',
- 'subsection',
- 'unnumberedsubsec',
- 'subheading',
- 'appendixsubsec',
- 'subsubsection',
- 'unnumberedsubsubsec',
- 'subsubheading',
- 'appendixsubsubsec',
- 'part',
- 'appendixsection',
- 'majorheading',
- 'chapheading',
- 'centerchap'
-) {
- $misc_commands{$sectioning_command} = 'line';
- if ($sectioning_command =~ /heading/) {
- $close_paragraph_commands{$sectioning_command} = 1;
- } else {
- $root_commands{$sectioning_command} = 1;
- }
- $sectioning_commands{$sectioning_command} = 1;
-}
-
-$root_commands{'node'} = 1;
-
-
-
-# charset related definitions.
-
-our %perl_charset_to_html = (
- 'utf8' => 'utf-8',
- 'utf-8-strict' => 'utf-8',
- 'ascii' => 'us-ascii',
- 'shiftjis' => 'shift_jis',
-);
-
-# encoding name normalization to html-compatible encoding names
-our %encoding_aliases = (
- 'latin1' => 'iso-8859-1',
-);
-
-foreach my $perl_charset (keys(%perl_charset_to_html)) {
- $encoding_aliases{$perl_charset} = $perl_charset_to_html{$perl_charset};
- $encoding_aliases{$perl_charset_to_html{$perl_charset}}
- = $perl_charset_to_html{$perl_charset};
-}
-our %eight_bit_encoding_aliases = (
- "iso-8859-1", 'iso8859_1',
- "iso-8859-2", 'iso8859_2',
- "iso-8859-15", 'iso8859_15',
- "koi8-r", 'koi8',
- "koi8-u", 'koi8',
-);
-
-foreach my $encoding (keys(%eight_bit_encoding_aliases)) {
- $encoding_aliases{$encoding} = $encoding;
- $encoding_aliases{$eight_bit_encoding_aliases{$encoding}} = $encoding;
-}
-
-
-1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Parser.pm Texinfo/Convert/No...,
Patrice Dumas <=