texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Wed, 2 Oct 2024 07:39:03 -0400 (EDT)

branch: master
commit 396e3c8eca05b5b1bef3bc32e51cedae06e38949
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Aug 1 09:56:37 2024 +0200

    * tp/maintain/regenerate_C_options_info.pl: fix parsing of converter
    defaults options with space.
    
    * tp/Makefile.am (Texinfo/Options.pm), tp/Texinfo/XS/Makefile.am
    (Options.pm), tp/maintain/regenerate_perl_options_info.pl: generate
    Perl data based on Texinfo/Convert/converters_defaults.txt.
    
    * tp/Texinfo/Convert/HTML.pm (%defaults): get options set from
    Texinfo/Convert/converters_defaults.txt.
---
 ChangeLog                                   | 12 +++++
 tp/Makefile.am                              |  9 ++--
 tp/Texinfo/Convert/HTML.pm                  | 60 +++----------------------
 tp/Texinfo/XS/Makefile.am                   | 11 +++--
 tp/Texinfo/XS/convert/converters_defaults.c |  2 +-
 tp/maintain/regenerate_C_options_info.pl    |  4 +-
 tp/maintain/regenerate_perl_options_info.pl | 69 ++++++++++++++++++++++++++++-
 7 files changed, 104 insertions(+), 63 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 180c4f16bb..d798c6e41c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-08-01  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/maintain/regenerate_C_options_info.pl: fix parsing of converter
+       defaults options with space.
+
+       * tp/Makefile.am (Texinfo/Options.pm), tp/Texinfo/XS/Makefile.am
+       (Options.pm), tp/maintain/regenerate_perl_options_info.pl: generate
+       Perl data based on Texinfo/Convert/converters_defaults.txt.
+
+       * tp/Texinfo/Convert/HTML.pm (%defaults): get options set from
+       Texinfo/Convert/converters_defaults.txt.
+
 2024-07-31  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Makefile.am (EXTRA_DIST),
diff --git a/tp/Makefile.am b/tp/Makefile.am
index de2673479b..4ddd2d60ab 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -384,10 +384,13 @@ Texinfo/ModulePath.pm: Texinfo/ModulePath.pm.in Makefile
 
 # FIXME duplicated in Texinfo/XS/Makefile.am. Remove from here?
 $(srcdir)/Texinfo/Commands.pm: Texinfo/command_data.txt 
$(srcdir)/maintain/regenerate_commands_perl_info.pl
-       $(srcdir)/maintain/regenerate_commands_perl_info.pl 
$(srcdir)/Texinfo/Commands.pm < $(srcdir)/Texinfo/command_data.txt
+       $(PERL) $(srcdir)/maintain/regenerate_commands_perl_info.pl 
$(srcdir)/Texinfo/Commands.pm < $(srcdir)/Texinfo/command_data.txt
 
-$(srcdir)/Texinfo/Options.pm: Texinfo/options_data.txt 
$(srcdir)/maintain/regenerate_perl_options_info.pl
-       $(srcdir)/maintain/regenerate_perl_options_info.pl 
$(srcdir)/Texinfo/Options.pm < $(srcdir)/Texinfo/options_data.txt
+$(srcdir)/Texinfo/Options.pm: Texinfo/Convert/converters_defaults.txt 
Texinfo/options_data.txt $(srcdir)/maintain/regenerate_perl_options_info.pl
+       $(PERL) $(srcdir)/maintain/regenerate_perl_options_info.pl \
+           $(srcdir)/Texinfo/Convert/converters_defaults.txt \
+           $(srcdir)/Texinfo/Options.pm \
+              < $(srcdir)/Texinfo/options_data.txt
 
 $(srcdir)/Texinfo/Data.pm: Texinfo/Data/default_css_element_class_styles.csv 
Texinfo/Data/default_direction_strings.csv 
Texinfo/Data/default_special_unit_info.csv 
Texinfo/Data/html_style_commands_element.csv 
$(srcdir)/maintain/generate_code_convert_data.pl
        $(srcdir)/maintain/generate_code_convert_data.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index a4fed373e1..ed8be4165d 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -64,6 +64,7 @@ use Texinfo::Convert::ConvertXS;
 use Texinfo::XSLoader;
 
 use Texinfo::Commands;
+use Texinfo::Options;
 use Texinfo::Common;
 use Texinfo::Data;
 use Texinfo::Config;
@@ -2511,65 +2512,16 @@ sub convert_tree_new_formatting_context($$$;$$$)
   return $result;
 }
 
+# values for integer and string options in code generated from
+# Texinfo/Convert/converters_defaults.txt
+my $regular_defaults = Texinfo::Options::get_converter_regular_options('html');
+
 my %defaults = (
   # Not a customization option variable
   'converted_format'   => 'html',
 
   # Customization option variables
-  'BIG_RULE'              => '<hr>',
-  'BODY_ELEMENT_ATTRIBUTES' => undef,
-  'CHAPTER_HEADER_LEVEL'  => 2,
-  'CLOSE_QUOTE_SYMBOL'    => undef,
-  'CONTENTS_OUTPUT_LOCATION' => 'after_top',
-  'CONVERT_TO_LATEX_IN_MATH' => undef,
-  'INDENTED_BLOCK_COMMANDS_IN_TABLE' => 0,
-  'COPIABLE_LINKS'        => 1,
-  'DATE_IN_HEADER'        => 0,
-  'DEFAULT_RULE'          => '<hr>',
-  'documentlanguage'      => 'en',
-  'DOCTYPE'               => '<!DOCTYPE html>',
-  'DO_ABOUT'              => 0,
-  'OUTPUT_CHARACTERS'     => 0,
-  'EXTENSION'             => 'html',
-  'EXTERNAL_CROSSREF_EXTENSION' => undef, # based on EXTENSION
-  'FOOTNOTE_END_HEADER_LEVEL' => 4,
-  'FOOTNOTE_SEPARATE_HEADER_LEVEL' => 4,
-  'FORMAT_MENU'           => 'sectiontoc',
-  'HEADERS'               => 1,
-  'INDEX_ENTRY_COLON'     => '',
-# if set style is added in attribute.
-  'INLINE_CSS_STYLE'      => 0,
-  'JS_WEBLABELS'          => 'generate',
-  'JS_WEBLABELS_FILE'     => 'js_licenses.html', # no clash with node name
-  'MAX_HEADER_LEVEL'      => 4,
-  'MENU_ENTRY_COLON'      => ':',
-  'MENU_SYMBOL'           => undef,
-  'MONOLITHIC'            => 1,
-  'NO_CUSTOM_HTML_ATTRIBUTE' => 0,
-# if set, no css is used.
-  'NO_CSS'                => 0,
-  'NO_NUMBER_FOOTNOTE_SYMBOL' => '*',
-  'NODE_NAME_IN_MENU'     => 1,
-  'OPEN_QUOTE_SYMBOL'     => undef,
-  'OUTPUT_ENCODING_NAME'  => 'utf-8',
-  'SECTION_NAME_IN_TITLE' => 0,
-  'SHORT_TOC_LINK_TO_TOC' => 1,
-  'SHOW_TITLE'            => undef,
-  'SPLIT'                 => 'node',
-  'TOP_FILE'              => 'index.html', # ignores EXTENSION
-  'TOP_NODE_FILE_TARGET'  => 'index.html', # ignores EXTENSION
-  'USE_ACCESSKEY'         => 1,
-  'USE_NEXT_HEADING_FOR_LONE_NODE' => 1,
-  'USE_ISO'               => 1,
-  'USE_LINKS'             => 1,
-  'USE_NODES'             => 1,
-  'USE_NODE_DIRECTIONS'   => undef,
-  'USE_REL_REV'           => 1,
-  'USE_TITLEPAGE_FOR_TITLE' => 1,
-  'WORDS_IN_PAGE'         => 300,
-  'XREF_USE_NODE_NAME_ARG' => undef, # for internal cross references
-  'XREF_USE_FLOAT_LABEL'   => 0,
-  'xrefautomaticsectiontitle' => 'on',
+  %{$regular_defaults},
 
   # Non-string customization variables
   # _default_panel_button_dynamic_direction use nodes direction based on 
USE_NODE_DIRECTIONS
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 4f24c8f6a0..a6cb193331 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -275,11 +275,16 @@ MAINTAINERCLEANFILES += main/global_commands_types.h
 
 # NOTE duplicate of a rule in ../../Makefile.am
 $(srcdir)/../Commands.pm: ../command_data.txt 
$(srcdir)/../../maintain/regenerate_commands_perl_info.pl
-       $(PERL) $(srcdir)/../../maintain/regenerate_commands_perl_info.pl 
$(srcdir)/../Commands.pm < $(srcdir)/../command_data.txt
+       $(PERL) $(srcdir)/../../maintain/regenerate_commands_perl_info.pl \
+         $(srcdir)/../Commands.pm \
+           < $(srcdir)/../command_data.txt
 
 # NOTE duplicate of a rule in ../../Makefile.am
-$(srcdir)/../Options.pm: $(srcdir)/../options_data.txt 
$(srcdir)/../../maintain/regenerate_perl_options_info.pl
-       $(PERL) $(srcdir)/../../maintain/regenerate_perl_options_info.pl 
$(srcdir)/../Options.pm < $(srcdir)/../options_data.txt
+$(srcdir)/../Options.pm: ../Convert/converters_defaults.txt 
../options_data.txt $(srcdir)/../../maintain/regenerate_perl_options_info.pl
+       $(PERL) $(srcdir)/../../maintain/regenerate_perl_options_info.pl \
+         $(srcdir)/../Convert/converters_defaults.txt \
+         $(srcdir)/../Options.pm \
+           < $(srcdir)/../options_data.txt
 
 $(srcdir)/main/cmd_normalization.c $(srcdir)/main/cmd_unicode.c 
$(srcdir)/main/cmd_structuring.c $(srcdir)/main/cmd_text.c 
$(srcdir)/convert/cmd_converter.c: main/command_data.c ../Commands.pm 
../Options.pm $(srcdir)/../../maintain/setup_converters_code_tables.pl
        $(TXI_MODULES_ENV) $(PERL) 
$(srcdir)/../../maintain/setup_converters_code_tables.pl \
diff --git a/tp/Texinfo/XS/convert/converters_defaults.c 
b/tp/Texinfo/XS/convert/converters_defaults.c
index 9130e70917..bc98cca600 100644
--- a/tp/Texinfo/XS/convert/converters_defaults.c
+++ b/tp/Texinfo/XS/convert/converters_defaults.c
@@ -19,7 +19,7 @@ void set_html_regular_options_defaults (OPTIONS *options)
   set_conf (&options->DATE_IN_HEADER, 0, 0);
   set_conf (&options->DEFAULT_RULE, -2, "<hr>");
   set_conf (&options->documentlanguage, -2, "en");
-  set_conf (&options->DOCTYPE, -2, "");
+  set_conf (&options->DOCTYPE, -2, "<!DOCTYPE html>");
   set_conf (&options->DO_ABOUT, 0, 0);
   set_conf (&options->OUTPUT_CHARACTERS, 0, 0);
   set_conf (&options->EXTENSION, -2, "html");
diff --git a/tp/maintain/regenerate_C_options_info.pl 
b/tp/maintain/regenerate_C_options_info.pl
index 129c4b763f..c2fcbb2ce7 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -107,7 +107,7 @@ while (<CDEF>) {
       if (/^ *([A-Za-z][A-Za-z0-9_]*)( +(.*))?$/) {
         my $option = $1;
         my $value = $3;
-        if (!defined($value) or $value =~ / +/) {
+        if (!defined($value) or $value =~ /^ +$/) {
           $value = '';
         }
         #print STDERR "$format|$variable|'$value'\n";
@@ -122,6 +122,8 @@ while (<CDEF>) {
   $line++;
 }
 
+close(CDEF);
+
 my $code_file = $ARGV[2];
 die "Need a code file\n" if (!defined($code_file));
 
diff --git a/tp/maintain/regenerate_perl_options_info.pl 
b/tp/maintain/regenerate_perl_options_info.pl
index 399fef2489..a7f6f4d65d 100755
--- a/tp/maintain/regenerate_perl_options_info.pl
+++ b/tp/maintain/regenerate_perl_options_info.pl
@@ -28,6 +28,8 @@ my $program_name = basename($0);
 
 my %option_categories;
 
+my %options;
+
 while (<STDIN>) {
   if (not (/^#/ or /^ *$/)) {
     if (/^([^ ]+) +([^ ]+) +([^ ]+) +(.+)$/) {
@@ -45,13 +47,58 @@ while (<STDIN>) {
       }
       push @{$option_categories{$category}}, [$option, $value, $type];
       #print STDERR "$option, $category, $value, $type\n";
+      $options{$option} = [$category, $value, $type];
     } else {
       warn "ERROR: unexpected line: $_";
     }
   }
 }
 
-my $out_file = $ARGV[0];
+my $converter_defaults_file = $ARGV[0];
+die "Need converter defaults file\n" if (!defined($converter_defaults_file));
+
+open(CDEF, $converter_defaults_file)
+  or die "open $converter_defaults_file: $!";
+
+my %converter_defaults;
+my $format;
+my $line = 1;
+while (<CDEF>) {
+  if (not (/^ *#/ or /^ *$/)) {
+    if (/^ *- *(\S+)/) {
+      $format = $1;
+      if (!defined($converter_defaults{$format})) {
+        $converter_defaults{$format} = [];
+      }
+    } elsif (defined($format)) {
+      if (/^ *([A-Za-z][A-Za-z0-9_]*)( +(.*))?$/) {
+        my $option = $1;
+        my $value = $3;
+        if (!defined($value) or $value =~ /^ +$/) {
+          $value = '';
+        }
+        #print STDERR "$format|$variable|'$value'\n";
+        if (!defined($options{$option})) {
+          print STDERR "$converter_defaults_file: $line: unknown option 
$option\n";
+        } else {
+          my $option_info = $options{$option};
+          my ($option_unused, $main_default, $type) = @$option_info;
+
+          if (($type eq 'char' or $type eq 'bytes') and $value ne 'undef') {
+            $value = "'".$value."'";
+          }
+          push @{$converter_defaults{$format}}, [$option, $value];
+        }
+      }
+    }
+  }
+  $line++;
+}
+
+close(CDEF);
+
+
+my $out_file = $ARGV[1];
 die "Need an output file\n" if (!defined($out_file));
 
 open (OUT, ">$out_file") or die "Open $out_file: $!\n";
@@ -69,5 +116,25 @@ foreach my $category (sort(keys(%option_categories))) {
   print OUT ");\n\n";
 }
 
+my @sorted_formats = sort(keys(%converter_defaults));
+
+my $function_lines = '';
+foreach my $format (@sorted_formats) {
+  my $hash = "%converter_${format}_regular_options_defaults";
+  print OUT "my $hash = (\n";
+  foreach my $option_spec (@{$converter_defaults{$format}}) {
+    my ($option, $value) = @$option_spec;
+    print OUT '  '.sprintf('%-34s', '"'.$option.'"')." => $value,\n";
+  }
+  print OUT ");\n\n";
+  $function_lines .= "  elsif (\$input eq '$format') \n   {return \\$hash;}\n"
+}
+
+print OUT "sub get_converter_regular_options {\n";
+print OUT "  my \$input = shift;\n";
+print OUT "  if (0) {}\n";
+print OUT $function_lines;
+print OUT "}\n\n";
+
 print OUT "1;\n";
 



reply via email to

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