[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Distinguish output and converted format, case of
From: |
Patrice Dumas |
Subject: |
branch master updated: Distinguish output and converted format, case of epub3/html |
Date: |
Sat, 30 Jul 2022 13:42:10 -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 1affe79281 Distinguish output and converted format, case of epub3/html
1affe79281 is described below
commit 1affe79281e7cbb8c085c7b2c1eb2ae3b92cc4ab
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 30 19:41:58 2022 +0200
Distinguish output and converted format, case of epub3/html
* tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/DocBook.pm,
tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/IXINSXML.pm,
tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
tp/Texinfo/Convert/TexinfoSXML.pm, tp/Texinfo/Convert/TexinfoXML.pm,
tp/texi2any.pl b/tp/texi2any.pl (set_format, %formats_table):
distinguish converted_format and output_format. output_format
is the format being output. converted_format corresponds to the
converter being used, it is the format of the conversion. In the
case of epub3, epub3 is the output_format and html is the
converted_format.
Change loading of epub3 to go through set_format, such that it may
be loaded with TEXINFO_OUTPUT_FORMAT too.
* tp/Texinfo/Common.pm (@variable_string_settables, tp/ext/epub3.pm):
make EPUB_CREATE_CONTAINER a valid customization in any case, such
that it can be set on the command line before the init file is loaded.
---
ChangeLog | 21 ++++++++++++
tp/Texinfo/Common.pm | 1 +
tp/Texinfo/Convert/Converter.pm | 3 ++
tp/Texinfo/Convert/DocBook.pm | 2 +-
tp/Texinfo/Convert/HTML.pm | 2 +-
tp/Texinfo/Convert/IXINSXML.pm | 2 +-
tp/Texinfo/Convert/LaTeX.pm | 2 +-
tp/Texinfo/Convert/Plaintext.pm | 6 ++--
tp/Texinfo/Convert/TexinfoSXML.pm | 2 +-
tp/Texinfo/Convert/TexinfoXML.pm | 2 +-
tp/ext/epub3.pm | 1 -
tp/t/test_utils.pl | 15 +++++----
tp/texi2any.pl | 71 ++++++++++++++++++++++++++-------------
13 files changed, 90 insertions(+), 40 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4e79ff71e8..1ff0a513f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2022-07-30 Patrice Dumas <pertusus@free.fr>
+
+ Distinguish output and converted format, case of epub3/html
+
+ * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/DocBook.pm,
+ tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/IXINSXML.pm,
+ tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
+ tp/Texinfo/Convert/TexinfoSXML.pm, tp/Texinfo/Convert/TexinfoXML.pm,
+ tp/texi2any.pl b/tp/texi2any.pl (set_format, %formats_table):
+ distinguish converted_format and output_format. output_format
+ is the format being output. converted_format corresponds to the
+ converter being used, it is the format of the conversion. In the
+ case of epub3, epub3 is the output_format and html is the
+ converted_format.
+ Change loading of epub3 to go through set_format, such that it may
+ be loaded with TEXINFO_OUTPUT_FORMAT too.
+
+ * tp/Texinfo/Common.pm (@variable_string_settables, tp/ext/epub3.pm):
+ make EPUB_CREATE_CONTAINER a valid customization in any case, such
+ that it can be set on the command line before the init file is loaded.
+
2022-07-30 Patrice Dumas <pertusus@free.fr>
Separate directory and loading function for init files used internally
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 198c28f356..d9d0020650 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -291,6 +291,7 @@ my @variable_string_settables = (
'DOC_ENCODING_FOR_INPUT_FILE_NAME',
'DOC_ENCODING_FOR_OUTPUT_FILE_NAME',
'DOCTYPE',
+'EPUB_CREATE_CONTAINER', # for ext/epub3.pm
'EXTENSION',
'EXTERNAL_CROSSREF_EXTENSION',
'EXTERNAL_CROSSREF_SPLIT',
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 0736b94b87..7ae507c02f 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -70,6 +70,9 @@ my %defaults = (
# items are not valid customization options?
my %common_converters_defaults = (
'language_config_dirs' => undef,
+ 'converted_format' => undef,
+ # can be different from the converted_format, for example, epub3
+ # output format converted format is html.
'output_format' => undef,
'structuring' => undef,
'translated_commands' => {'error' => 'error@arrow{}',},
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 920a6dbad3..b2ca2f1d1f 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -51,7 +51,7 @@ my %defaults = (
'OUTPUT_ENCODING_NAME' => 'utf-8',
'OUTFILE' => undef,
'SUBDIR' => undef,
- 'output_format' => 'docbook',
+ 'converted_format' => 'docbook',
'SPLIT' => 0,
'documentlanguage' => undef,
'OPEN_QUOTE_SYMBOL' => '&#'.hex('2018').';',
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 16adb69388..143574b349 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -1857,7 +1857,7 @@ my %defaults = (
},
'COPIABLE_LINKS' => 1,
- 'output_format' => 'html',
+ 'converted_format' => 'html',
);
foreach my $buttons ('CHAPTER_BUTTONS', 'MISC_BUTTONS', 'TOP_BUTTONS') {
diff --git a/tp/Texinfo/Convert/IXINSXML.pm b/tp/Texinfo/Convert/IXINSXML.pm
index 594b343875..59eb8bbfd2 100644
--- a/tp/Texinfo/Convert/IXINSXML.pm
+++ b/tp/Texinfo/Convert/IXINSXML.pm
@@ -49,7 +49,7 @@ my %defaults = (
'TEXINFO_DTD_VERSION' => '5.0',
'OUTFILE' => undef,
'SUBDIR' => undef,
- 'output_format' => 'ixinsxml',
+ 'converted_format' => 'ixinsxml',
'SPLIT' => 0,
'documentlanguage' => 'en',
'USE_NODES' => 1,
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 46f6cd7ac0..4602d99b57 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -795,7 +795,7 @@ my %defaults = (
'SUBDIR' => undef,
'documentlanguage' => undef,
- 'output_format' => 'latex',
+ 'converted_format' => 'latex',
# FIXME any idea what could be used?
'floats_extension' => 'tfl',
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index e57d7b051d..4e40bd598c 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -348,7 +348,7 @@ my %defaults = (
'SUBDIR' => undef,
'documentlanguage' => undef,
- 'output_format' => '',
+ 'converted_format' => '',
'USE_NODES' => 1,
);
@@ -1819,8 +1819,8 @@ sub _convert($$)
and scalar (@{$element->{'args'}->[0]->{'contents'}})
and $element->{'args'}->[0]->{'contents'}->[0]->{'text'}
and $element->{'args'}->[0]->{'contents'}->[0]->{'text'} =~
/^Note\s/i
- and $self->{'output_format'}
- and $self->{'output_format'} eq 'info') {
+ and $self->{'converted_format'}
+ and $self->{'converted_format'} eq 'info') {
$self->line_warn($self, __(
"\@strong{Note...} produces a spurious cross-reference in Info; reword to
avoid that"),
$element->{'source_info'});
diff --git a/tp/Texinfo/Convert/TexinfoSXML.pm
b/tp/Texinfo/Convert/TexinfoSXML.pm
index 78258cc3fd..534879d813 100644
--- a/tp/Texinfo/Convert/TexinfoSXML.pm
+++ b/tp/Texinfo/Convert/TexinfoSXML.pm
@@ -44,7 +44,7 @@ my %defaults = (
'TEXINFO_DTD_VERSION' => '5.0',
'OUTFILE' => undef,
'SUBDIR' => undef,
- 'output_format' => 'texinfosxml',
+ 'converted_format' => 'texinfosxml',
'SPLIT' => 0,
'documentlanguage' => 'en',
);
diff --git a/tp/Texinfo/Convert/TexinfoXML.pm b/tp/Texinfo/Convert/TexinfoXML.pm
index 28e5b1d6f3..9ef1c7344c 100644
--- a/tp/Texinfo/Convert/TexinfoXML.pm
+++ b/tp/Texinfo/Convert/TexinfoXML.pm
@@ -46,7 +46,7 @@ my %defaults = (
'TEXINFO_DTD_VERSION' => '5.0',
'OUTFILE' => undef,
'SUBDIR' => undef,
- 'output_format' => 'xml',
+ 'converted_format' => 'xml',
'SPLIT' => 0,
'documentlanguage' => 'en',
);
diff --git a/tp/ext/epub3.pm b/tp/ext/epub3.pm
index 4b508831db..eaa4d39275 100644
--- a/tp/ext/epub3.pm
+++ b/tp/ext/epub3.pm
@@ -61,7 +61,6 @@ use Texinfo::Convert::Text;
my $epub_format_version = '3.2';
# used in tests to avoid creating the .epub file.
-texinfo_add_valid_customization_option('EPUB_CREATE_CONTAINER');
texinfo_set_from_init_file('EPUB_CREATE_CONTAINER', 1);
texinfo_set_format_from_init_file('html');
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index ad2aee1f5c..9f02c67f1c 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -525,6 +525,9 @@ sub set_converter_option_defaults($$$)
if (!defined($converter_options->{'EXPANDED_FORMATS'})) {
$converter_options->{'EXPANDED_FORMATS'} = [$format];
}
+ if (!defined($converter_options->{'output_format'})) {
+ $converter_options->{'output_format'} = $format;
+ }
return $converter_options;
}
@@ -566,7 +569,7 @@ sub convert_to_plaintext($$$$$$;$)
my $converter =
Texinfo::Convert::Plaintext->converter({'DEBUG' => $self->{'DEBUG'},
'parser' => $parser,
- 'output_format' => 'plaintext',
+ 'converted_format' => 'plaintext',
%$converter_options });
my $result;
if ($converter_options->{'OUTFILE'} eq '') {
@@ -597,7 +600,7 @@ sub convert_to_info($$$$$;$)
my $converter =
Texinfo::Convert::Info->converter ({'DEBUG' => $self->{'DEBUG'},
'parser' => $parser,
- 'output_format' => 'info',
+ 'converted_format' => 'info',
%$converter_options });
my $result = $converter->output($tree);
close_files($converter);
@@ -625,7 +628,7 @@ sub convert_to_html($$$$$$;$)
my $converter =
Texinfo::Convert::HTML->converter ({'DEBUG' => $self->{'DEBUG'},
'parser' => $parser,
- 'output_format' => 'html',
+ 'converted_format' => 'html',
%$converter_options });
my $result;
if ($format eq 'html_text') {
@@ -657,7 +660,7 @@ sub convert_to_xml($$$$$$;$)
my $converter =
Texinfo::Convert::TexinfoXML->converter ({'DEBUG' => $self->{'DEBUG'},
'parser' => $parser,
- 'output_format' => 'texinfoxml',
+ 'converted_format' => 'texinfoxml',
%$converter_options });
my $result;
@@ -689,7 +692,7 @@ sub convert_to_docbook($$$$$$;$)
my $converter =
Texinfo::Convert::DocBook->converter ({'DEBUG' => $self->{'DEBUG'},
'parser' => $parser,
- 'output_format' => 'docbook',
+ 'converted_format' => 'docbook',
%$converter_options });
my $result;
my $tree_for_conversion;
@@ -737,7 +740,7 @@ sub convert_to_latex($$$$$$;$)
my $converter =
Texinfo::Convert::LaTeX->converter ({'DEBUG' => $self->{'DEBUG'},
'parser' => $parser,
- 'output_format' => 'latex',
+ 'converted_format' => 'latex',
%$converter_options });
my $result;
if (defined($converter_options->{'OUTFILE'})
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 8ad4daa759..54288a6177 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -594,6 +594,10 @@ my %formats_table = (
'no_warn_non_empty_parts' => 1,
'module' => 'Texinfo::Convert::DocBook'
},
+ 'epub3' => {
+ 'converted_format' => 'html',
+ 'init_file' => 'epub3.pm',
+ },
'pdf' => {
'texi2dvi_format' => 1,
},
@@ -658,6 +662,8 @@ sub set_format($;$$)
$call_texi2dvi = 1;
push @texi2dvi_args, '--'.$new_format;
$expanded_format = 'tex';
+ } elsif ($formats_table{$new_format}->{'converted_format'}) {
+ $expanded_format = $formats_table{$new_format}->{'converted_format'};
}
if ($Texinfo::Common::texinfo_output_formats{$expanded_format}) {
if ($expanded_format eq 'plaintext') {
@@ -1064,11 +1070,7 @@ There is NO WARRANTY, to the extent permitted by
law.\n"), "2021");
'silent|quiet' => sub { push @texi2dvi_args, '--'.$_[0];},
'plaintext' => sub {$format = set_format($_[0].'');},
'html' => sub {$format = set_format($_[0].'');},
- 'epub3' => sub {
- $format = set_format('html');
- my $epub_file = 'epub3.pm';
- locate_and_load_extension_file($epub_file, $internal_extension_dirs);
- },
+ 'epub3' => sub {$format = set_format($_[0].'');},
'latex' => sub {$format = set_format($_[0].'');},
'info' => sub {$format = set_format($_[0].'');},
'docbook' => sub {$format = set_format($_[0].'');},
@@ -1136,8 +1138,9 @@ my %format_names = (
'info' => 'Info',
'html' => 'HTML',
'docbook' => 'DocBook',
- 'texinfoxml' => 'Texinfo XML',
+ 'epub3' => 'EPUB 3',
'plaintext' => 'Plain Text',
+ 'texinfoxml' => 'Texinfo XML',
);
sub format_name($)
@@ -1161,6 +1164,12 @@ if (defined($ENV{'TEXINFO_OUTPUT_FORMAT'})
$format, 1);
}
+# for a format setup with an init file
+if (defined ($formats_table{$format}->{'init_file'})) {
+ locate_and_load_extension_file($formats_table{$format}->{'init_file'},
+ $internal_extension_dirs);
+}
+
if ($call_texi2dvi) {
if (defined(get_conf('OUTFILE')) and @ARGV > 1) {
die sprintf(__('%s: when generating %s, only one input FILE may be
specified with -o'."\n"),
@@ -1189,9 +1198,19 @@ if (get_conf('TREE_TRANSFORMATIONS')) {
}
}
-if (get_conf('SPLIT') and !$formats_table{$format}->{'split'}) {
+# in general the format name is the format being converted. If this is
+# not the case, the converted format is set here. For example, for
+# the epub3 format, the converted format is html.
+my $converted_format = $format;
+if ($formats_table{$format}->{'converted_format'}) {
+ $converted_format = $formats_table{$format}->{'converted_format'};
+}
+
+# FIXME distinguish format and converted_format in message?
+if (get_conf('SPLIT') and !$formats_table{$converted_format}->{'split'}) {
+ #document_warn(sprintf(__('ignoring splitting for converted format %s'),
document_warn(sprintf(__('ignoring splitting for format %s'),
- format_name($format)));
+ format_name($converted_format)));
set_from_cmdline('SPLIT', '');
}
@@ -1200,14 +1219,14 @@ add_to_option_list('EXPANDED_FORMATS',
$default_expanded_format);
my $converter_class;
my %converter_defaults;
-if (defined($formats_table{$format}->{'module'})) {
+if (defined($formats_table{$converted_format}->{'module'})) {
# Speed up initialization by only loading the module we need.
- my $module = $formats_table{$format}->{'module'};
+ my $module = $formats_table{$converted_format}->{'module'};
eval "require $module" or die "$@";
eval "$module->import;";
- eval '$formats_table{$format}->{\'converter\'} = sub{'.
- $formats_table{$format}->{'module'}
+ eval '$formats_table{$converted_format}->{\'converter\'} = sub{'.
+ $formats_table{$converted_format}->{'module'}
.'->converter(@_)};';
}
@@ -1221,8 +1240,8 @@ if (defined($formats_table{$format}->{'module'})) {
# even if the command line higher precedence option is set in case
# command line is set_format_menu_from_cmdline_header.
my $conversion_format_menu_default;
-if (defined($formats_table{$format}->{'module'})) {
- $converter_class = $formats_table{$format}->{'module'};
+if (defined($formats_table{$converted_format}->{'module'})) {
+ $converter_class = $formats_table{$converted_format}->{'module'};
# $cmdline_options is passed to have command line settings, here
# in practice TEXI2HTML set, for conversion to HTML to select
# possibly different customization variable values.
@@ -1357,7 +1376,7 @@ while(@input_files) {
my ($labels, $targets_list, $nodes_list) = $parser->labels_information();
if ((get_conf('SIMPLE_MENU')
- and $formats_table{$format}->{'simple_menu'})
+ and $formats_table{$converted_format}->{'simple_menu'})
or $tree_transformations{'simple_menus'}) {
Texinfo::Transformations::set_menus_to_simple_menu($nodes_list);
}
@@ -1426,17 +1445,17 @@ while(@input_files) {
next;
}
- if ($formats_table{$format}->{'move_index_entries_after_items'}
+ if ($formats_table{$converted_format}->{'move_index_entries_after_items'}
or $tree_transformations{'move_index_entries_after_items'}) {
Texinfo::Common::move_index_entries_after_items_in_tree($tree);
}
- if ($formats_table{$format}->{'relate_index_entries_to_table_entries'}
+ if
($formats_table{$converted_format}->{'relate_index_entries_to_table_entries'}
or $tree_transformations{'relate_index_entries_to_table_entries'}) {
Texinfo::Common::relate_index_entries_to_table_entries_in_tree($tree);
}
- if ($formats_table{$format}->{'joint_transformation'}) {
+ if ($formats_table{$converted_format}->{'joint_transformation'}) {
Texinfo::Common::html_joint_transformation($tree);
}
@@ -1469,7 +1488,7 @@ while(@input_files) {
if ($sectioning_root) {
$structure_information->{'sectioning_root'} = $sectioning_root;
$structure_information->{'sections_list'} = $sections_list;
- if (!$formats_table{$format}->{'no_warn_non_empty_parts'}) {
+ if (!$formats_table{$converted_format}->{'no_warn_non_empty_parts'}) {
Texinfo::Structuring::warn_non_empty_parts($registrar,
$main_configuration,
$global_commands);
}
@@ -1490,7 +1509,7 @@ while(@input_files) {
my $floats = $parser->floats_information();
my $top_node;
- if ($formats_table{$format}->{'nodes_tree'}) {
+ if ($formats_table{$converted_format}->{'nodes_tree'}) {
# FIXME makes implicitely menu the default here. 'FORMAT_MENU'
# not being set here happens rarely, when there is a format, but the
@@ -1518,7 +1537,7 @@ while(@input_files) {
}
}
}
- if ($formats_table{$format}->{'floats'}) {
+ if ($formats_table{$converted_format}->{'floats'}) {
Texinfo::Structuring::number_floats($floats);
}
@@ -1555,11 +1574,13 @@ while(@input_files) {
$converter_options->{'parser'} = $parser;
$converter_options->{'structuring'} = $structure_information;
$converter_options->{'output_format'} = $format;
+ $converter_options->{'converted_format'} = $converted_format;
$converter_options->{'language_config_dirs'} = \@language_config_dirs;
unshift @{$converter_options->{'INCLUDE_DIRECTORIES'}},
@prepended_include_directories;
- my $converter =
&{$formats_table{$format}->{'converter'}}($converter_options);
+ my $converter = &{$formats_table{$converted_format}
+ ->{'converter'}}($converter_options);
$converter->output($tree);
push @opened_files, Texinfo::Common::output_files_opened_files(
$converter->output_files_information());
@@ -1584,7 +1605,7 @@ while(@input_files) {
}
if (defined(get_conf('INTERNAL_LINKS')) and $file_number == 0
- and $formats_table{$format}->{'internal_links'}) {
+ and $formats_table{$converted_format}->{'internal_links'}) {
my $internal_links_text
= $converter->output_internal_links();
# always create a file, even if empty.
@@ -1628,7 +1649,9 @@ while(@input_files) {
require Texinfo::Convert::Converter;
my $converter_element_count_file
= Texinfo::Convert::TextContent->converter($converter_options);
- my $use_sections = (! $formats_table{$format}->{'nodes_tree'}
+ # here could be $format or $converted_format. Since $converted_format
+ # is used above for ->{'nodes_tree'}, use it here again.
+ my $use_sections = (! $formats_table{$converted_format}->{'nodes_tree'}
or (defined($converter->get_conf('USE_NODES'))
and !$converter->get_conf('USE_NODES')));
my ($sorted_name_counts_array, $sort_element_count_text)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Distinguish output and converted format, case of epub3/html,
Patrice Dumas <=