[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * Texinfo/Convert/DocBook.pm: rename $root as $el
From: |
Patrice Dumas |
Subject: |
branch master updated: * Texinfo/Convert/DocBook.pm: rename $root as $element if not a root element, and element as format_element for DocBook elements. |
Date: |
Wed, 08 Sep 2021 09:52:48 -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 da52595 * Texinfo/Convert/DocBook.pm: rename $root as $element if not
a root element, and element as format_element for DocBook elements.
da52595 is described below
commit da52595767f7224346180dc7daf3b7aa66095c7c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Sep 8 15:52:40 2021 +0200
* Texinfo/Convert/DocBook.pm: rename $root as $element if not
a root element, and element as format_element for DocBook elements.
---
ChangeLog | 5 +
tp/Texinfo/Convert/DocBook.pm | 700 +++++++++++++++++++++---------------------
2 files changed, 355 insertions(+), 350 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dc3e0d2..030eeb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2021-09-08 Patrice Dumas <pertusus@free.fr>
+ * Texinfo/Convert/DocBook.pm: rename $root as $element if not
+ a root element, and element as format_element for DocBook elements.
+
+2021-09-08 Patrice Dumas <pertusus@free.fr>
+
* tp/Texinfo/Convert/HTML.pm (_html_get_tree_root_element)
(command_filename, command_root_element_command)
(_prepare_tree_root_elements):
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 5db4df3..74900d7 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -391,17 +391,18 @@ foreach my $special_unnumbered ('acknowledgements',
'colophon',
sub _docbook_section_element($$)
{
my $self = shift;
- my $root = shift;
- my $heading_level = $root->{'level'};
+ my $element = shift;
+
+ my $heading_level = $element->{'level'};
if (exists $docbook_sections{$heading_level}) {
return $docbook_sections{$heading_level};
}
- my $command = $self->_level_corrected_section($root);
+ my $command = $self->_level_corrected_section($element);
if ($command eq 'unnumbered'
- and $root->{'extra'}->{'associated_node'}
- and $root->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'}
- and
$docbook_special_unnumbered{lc($root->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'})})
{
- return
lc($root->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'});
+ and $element->{'extra'}->{'associated_node'}
+ and $element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'}
+ and
$docbook_special_unnumbered{lc($element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'})})
{
+ return
lc($element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'});
}
return $docbook_sections{$command};
@@ -410,9 +411,9 @@ sub _docbook_section_element($$)
sub _index_entry($$)
{
my $self = shift;
- my $root = shift;
- if ($root->{'extra'} and $root->{'extra'}->{'index_entry'}) {
- my $index_entry = $root->{'extra'}->{'index_entry'};
+ my $element = shift;
+ if ($element->{'extra'} and $element->{'extra'}->{'index_entry'}) {
+ my $index_entry = $element->{'extra'}->{'index_entry'};
# FIXME DocBook 5 role->type
my $result = "<indexterm role=\"$index_entry->{'index_name'}\">";
@@ -501,14 +502,14 @@ sub _protect_text($$)
sub _convert_argument_and_end_line($$)
{
my $self = shift;
- my $root = shift;
+ my $element = shift;
- my $converted = $self->convert_tree($root->{'args'}->[-1]);
+ my $converted = $self->convert_tree($element->{'args'}->[-1]);
my $end_line = '';
- if ($root->{'extra'} and $root->{'extra'}->{'comment_at_end'}) {
- $end_line = $self->convert_tree($root->{'extra'}->{'comment_at_end'});
+ if ($element->{'extra'} and $element->{'extra'}->{'comment_at_end'}) {
+ $end_line = $self->convert_tree($element->{'extra'}->{'comment_at_end'});
} else {
if (chomp($converted)) {
$end_line = "\n";
@@ -526,32 +527,32 @@ sub _convert($$;$);
sub _convert($$;$)
{
my $self = shift;
- my $root = shift;
+ my $element = shift;
#if (1) {
if (0) { # too verbose even for debugging, but for the bottom line ...
warn "root\n";
- warn " Command: $root->{'cmdname'}\n" if ($root->{'cmdname'});
- warn " Type: $root->{'type'}\n" if ($root->{'type'});
- warn " Text: $root->{'text'}\n" if (defined($root->{'text'}));
- #warn " Special def_command: $root->{'extra'}->{'def_command'}\n"
- # if (defined($root->{'extra'}) and $root->{'extra'}->{'def_command'});
+ warn " Command: $element->{'cmdname'}\n" if ($element->{'cmdname'});
+ warn " Type: $element->{'type'}\n" if ($element->{'type'});
+ warn " Text: $element->{'text'}\n" if (defined($element->{'text'}));
+ #warn " Special def_command: $element->{'extra'}->{'def_command'}\n"
+ # if (defined($element->{'extra'}) and
$element->{'extra'}->{'def_command'});
}
- return '' if ($root->{'type'} and $ignored_types{$root->{'type'}});
+ return '' if ($element->{'type'} and $ignored_types{$element->{'type'}});
my $result = '';
- if (defined($root->{'text'})) {
- if (defined($root->{'type'}) and $root->{'type'} eq '_converted') {
- return $root->{'text'};
+ if (defined($element->{'text'})) {
+ if (defined($element->{'type'}) and $element->{'type'} eq '_converted') {
+ return $element->{'text'};
} elsif ($self->{'document_context'}->[-1]->{'raw'}) {
- return $root->{'text'};
+ return $element->{'text'};
}
- $result = $root->{'text'};
+ $result = $element->{'text'};
if ($self->{'document_context'}->[-1]->{'upper_case'}->[-1]) {
$result = uc($result);
}
$result = $self->_protect_text($result);
- if (! defined($root->{'type'}) or $root->{'type'} ne 'raw') {
+ if (! defined($element->{'type'}) or $element->{'type'} ne 'raw') {
if (!$self->{'document_context'}->[-1]->{'monospace'}->[-1]) {
$result =~ s/``/$ldquo/g;
$result =~ s/\'\'/$rdquo/g;
@@ -561,27 +562,27 @@ sub _convert($$;$)
$result =~ s/--/$ndash/g;
}
}
- #warn "had text `$root->{'text'}', returning $result\n";
+ #warn "had text `$element->{'text'}', returning $result\n";
return $result;
}
#warn " onto main conditional\n";
- my @close_elements;
- if ($root->{'cmdname'}) {
- #warn " got cmdname $root->{'cmdname'}\n";
- if (defined($docbook_no_arg_commands_formatting{$root->{'cmdname'}})) {
+ my @close_format_elements;
+ if ($element->{'cmdname'}) {
+ #warn " got cmdname $element->{'cmdname'}\n";
+ if (defined($docbook_no_arg_commands_formatting{$element->{'cmdname'}})) {
#warn " has no_arg_commands_formatting \n";
my $command;
- if ($root->{'cmdname'} eq 'click'
- and $root->{'extra'}
- and defined($root->{'extra'}->{'clickstyle'})) {
- $command = $root->{'extra'}->{'clickstyle'};
+ if ($element->{'cmdname'} eq 'click'
+ and $element->{'extra'}
+ and defined($element->{'extra'}->{'clickstyle'})) {
+ $command = $element->{'extra'}->{'clickstyle'};
} elsif ($self->{'document_context'}->[-1]->{'upper_case'}->[-1]
- and $Texinfo::Common::letter_no_arg_commands{$root->{'cmdname'}}
- and
$Texinfo::Common::letter_no_arg_commands{uc($root->{'cmdname'})}) {
- $command = uc($root->{'cmdname'})
+ and
$Texinfo::Common::letter_no_arg_commands{$element->{'cmdname'}}
+ and
$Texinfo::Common::letter_no_arg_commands{uc($element->{'cmdname'})}) {
+ $command = uc($element->{'cmdname'})
} else {
- $command = $root->{'cmdname'};
+ $command = $element->{'cmdname'};
}
my $translated_tree =
Texinfo::Convert::Utils::translated_command_tree($self,
$command);
@@ -590,59 +591,59 @@ sub _convert($$;$)
} else {
return $docbook_no_arg_commands_formatting{$command};
}
- } elsif ($root->{'cmdname'} eq 'today') {
+ } elsif ($element->{'cmdname'} eq 'today') {
return $self->_convert(Texinfo::Convert::Utils::expand_today($self));
- } elsif ($Texinfo::Common::accent_commands{$root->{'cmdname'}}) {
- return $self->convert_accents($root, \&docbook_accent,
+ } elsif ($Texinfo::Common::accent_commands{$element->{'cmdname'}}) {
+ return $self->convert_accents($element, \&docbook_accent,
$self->{'document_context'}->[-1]->{'upper_case'}->[-1]);
- } elsif ($root->{'cmdname'} eq 'item' or $root->{'cmdname'} eq 'itemx'
- or $root->{'cmdname'} eq 'headitem' or $root->{'cmdname'} eq
'tab') {
- if ($root->{'cmdname'} eq 'item'
- and $root->{'parent'}->{'cmdname'}
- and ($root->{'parent'}->{'cmdname'} eq 'itemize'
- or $root->{'parent'}->{'cmdname'} eq 'enumerate')) {
+ } elsif ($element->{'cmdname'} eq 'item' or $element->{'cmdname'} eq
'itemx'
+ or $element->{'cmdname'} eq 'headitem' or $element->{'cmdname'}
eq 'tab') {
+ if ($element->{'cmdname'} eq 'item'
+ and $element->{'parent'}->{'cmdname'}
+ and ($element->{'parent'}->{'cmdname'} eq 'itemize'
+ or $element->{'parent'}->{'cmdname'} eq 'enumerate')) {
$result .= "<listitem>";
- if ($root->{'parent'}->{'cmdname'} eq 'itemize'
- and $root->{'parent'}->{'extra'}
- and !($root->{'parent'}->{'extra'}->{'command_as_argument'}
- and
$root->{'parent'}->{'extra'}->{'command_as_argument'}->{'cmdname'} eq 'bullet')
- and $root->{'parent'}->{'args'}
- and $root->{'parent'}->{'args'}->[0]) {
+ if ($element->{'parent'}->{'cmdname'} eq 'itemize'
+ and $element->{'parent'}->{'extra'}
+ and !($element->{'parent'}->{'extra'}->{'command_as_argument'}
+ and
$element->{'parent'}->{'extra'}->{'command_as_argument'}->{'cmdname'} eq
'bullet')
+ and $element->{'parent'}->{'args'}
+ and $element->{'parent'}->{'args'}->[0]) {
$self->{'pending_prepend'}
- = $self->_convert($root->{'parent'}->{'args'}->[0]);
+ = $self->_convert($element->{'parent'}->{'args'}->[0]);
$self->{'pending_prepend'} .= " ";
}
- push @close_elements, 'listitem';
- } elsif (($root->{'cmdname'} eq 'item' or $root->{'cmdname'} eq 'itemx')
- and $root->{'parent'}->{'type'}
- and $root->{'parent'}->{'type'} eq 'table_term') {
+ push @close_format_elements, 'listitem';
+ } elsif (($element->{'cmdname'} eq 'item' or $element->{'cmdname'} eq
'itemx')
+ and $element->{'parent'}->{'type'}
+ and $element->{'parent'}->{'type'} eq 'table_term') {
- my $converted_tree = $self->_table_item_content_tree($root,
- $root->{'args'}->[0]->{'contents'});
+ my $converted_tree = $self->_table_item_content_tree($element,
+
$element->{'args'}->[0]->{'contents'});
$result .= "<term>";
- $result .= $self->_index_entry($root);
+ $result .= $self->_index_entry($element);
$result .= $self->_convert($converted_tree);
chomp ($result);
$result .= "\n";
$result .= "</term>";
} else {
- unless (($root->{'cmdname'} eq 'item'
- or $root->{'cmdname'} eq 'headitem'
- or $root->{'cmdname'} eq 'tab')
- and $root->{'parent'}->{'type'}
- and $root->{'parent'}->{'type'} eq 'row') {
+ unless (($element->{'cmdname'} eq 'item'
+ or $element->{'cmdname'} eq 'headitem'
+ or $element->{'cmdname'} eq 'tab')
+ and $element->{'parent'}->{'type'}
+ and $element->{'parent'}->{'type'} eq 'row') {
warn "BUG: multitable cell command not in a row "
- .Texinfo::Common::_print_current($root);
+ .Texinfo::Common::_print_current($element);
}
$result .= "<entry>";
- push @close_elements, 'entry';
+ push @close_format_elements, 'entry';
}
- } elsif ($root->{'type'} and $root->{'type'} eq 'index_entry_command') {
+ } elsif ($element->{'type'} and $element->{'type'} eq
'index_entry_command') {
my $end_line;
- if ($root->{'args'}->[0]) {
- $end_line = $self->_end_line_or_comment($root);
+ if ($element->{'args'}->[0]) {
+ $end_line = $self->_end_line_or_comment($element);
if ($self->{'document_context'}->[-1]->{'in_preformatted'}) {
chomp($end_line);
}
@@ -650,23 +651,23 @@ sub _convert($$;$)
# May that happen?
$end_line = '';
}
- return $self->_index_entry($root).${end_line};
+ return $self->_index_entry($element).${end_line};
- } elsif (exists($docbook_misc_commands{$root->{'cmdname'}})) {
+ } elsif (exists($docbook_misc_commands{$element->{'cmdname'}})) {
#warn " is dbk misc command\n";
- if ($docbook_global_commands{$root->{'cmdname'}}) {
- $self->set_informative_command_value($root);
+ if ($docbook_global_commands{$element->{'cmdname'}}) {
+ $self->set_informative_command_value($element);
return '';
}
my $command;
- if (exists ($docbook_misc_elements_with_arg_map{$root->{'cmdname'}})) {
- $command = $docbook_misc_elements_with_arg_map{$root->{'cmdname'}};
+ if (exists ($docbook_misc_elements_with_arg_map{$element->{'cmdname'}}))
{
+ $command = $docbook_misc_elements_with_arg_map{$element->{'cmdname'}};
}
- my $type = $docbook_misc_commands{$root->{'cmdname'}};
+ my $type = $docbook_misc_commands{$element->{'cmdname'}};
if ($type eq 'text') {
- if ($root->{'cmdname'} eq 'verbatiminclude') {
+ if ($element->{'cmdname'} eq 'verbatiminclude') {
my $verbatim_include_verbatim
- = Texinfo::Convert::Utils::expand_verbatiminclude($self, $self,
$root);
+ = Texinfo::Convert::Utils::expand_verbatiminclude($self, $self,
$element);
if (defined($verbatim_include_verbatim)) {
$result .= $self->_convert($verbatim_include_verbatim);
} else {
@@ -676,31 +677,31 @@ sub _convert($$;$)
return '';
}
} elsif ($type eq 'line') {
- if ($root->{'cmdname'} eq 'node') {
- if ($root->{'extra'} and !$root->{'extra'}->{'associated_section'}
- and defined($root->{'extra'}->{'normalized'})) {
- $result .= "<anchor id=\"$root->{'extra'}->{'normalized'}\"/>\n";
+ if ($element->{'cmdname'} eq 'node') {
+ if ($element->{'extra'} and
!$element->{'extra'}->{'associated_section'}
+ and defined($element->{'extra'}->{'normalized'})) {
+ $result .= "<anchor
id=\"$element->{'extra'}->{'normalized'}\"/>\n";
}
- } elsif ($Texinfo::Common::root_commands{$root->{'cmdname'}}) {
+ } elsif ($Texinfo::Common::root_commands{$element->{'cmdname'}}) {
my $attribute = '';
# FIXME it is not clear that a label should be set for
# @appendix* or @chapter/@*section as the formatter should be
# able to figure it out. For @unnumbered or if ! NUMBER_SECTIONS
# having a label (empty) is important.
my $label = '';
- if (defined($root->{'number'})
+ if (defined($element->{'number'})
and ($self->get_conf('NUMBER_SECTIONS')
or !defined($self->get_conf('NUMBER_SECTIONS')))) {
# Looking at docbook2html output, Appendix is appended in the
# section title, so only the letter is used.
- $label = $root->{'number'};
+ $label = $element->{'number'};
}
- $command = $self->_docbook_section_element($root);
+ $command = $self->_docbook_section_element($element);
if (! $docbook_special_unnumbered{$command}) {
$attribute = " label=\"$label\"";
}
- if ($root->{'extra'} and $root->{'extra'}->{'associated_node'}) {
- $attribute .= "
id=\"$root->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'}\"";
+ if ($element->{'extra'} and
$element->{'extra'}->{'associated_node'}) {
+ $attribute .= "
id=\"$element->{'extra'}->{'associated_node'}->{'extra'}->{'normalized'}\"";
}
my $language = '';
if (defined($self->get_conf('documentlanguage'))) {
@@ -711,20 +712,20 @@ sub _convert($$;$)
}
push @{$self->{'lang_stack'}}, $language;
$result .= "<$command${attribute}>\n";
- if ($root->{'args'} and $root->{'args'}->[0]) {
- my ($arg, $end_line) =
$self->_convert_argument_and_end_line($root);
+ if ($element->{'args'} and $element->{'args'}->[0]) {
+ my ($arg, $end_line) =
$self->_convert_argument_and_end_line($element);
$result .= "<title>$arg</title>$end_line";
chomp ($result);
$result .= "\n";
}
- if ($command eq 'part' and
!Texinfo::Common::is_content_empty($root)) {
+ if ($command eq 'part' and
!Texinfo::Common::is_content_empty($element)) {
$result .= "<partintro>\n";
}
- } elsif ($Texinfo::Common::sectioning_commands{$root->{'cmdname'}}) {
- if ($root->{'args'} and $root->{'args'}->[0]) {
- my ($arg, $end_line) =
$self->_convert_argument_and_end_line($root);
+ } elsif ($Texinfo::Common::sectioning_commands{$element->{'cmdname'}})
{
+ if ($element->{'args'} and $element->{'args'}->[0]) {
+ my ($arg, $end_line) =
$self->_convert_argument_and_end_line($element);
$result .=
- "<bridgehead
renderas=\"$docbook_sections{$root->{'cmdname'}}\">$arg</bridgehead>$end_line";
+ "<bridgehead
renderas=\"$docbook_sections{$element->{'cmdname'}}\">$arg</bridgehead>$end_line";
chomp ($result);
$result .= "\n";
return $result;
@@ -734,7 +735,7 @@ sub _convert($$;$)
my $attribute = '';
if (defined($command)) {
my ($arg, $end_line)
- = $self->_convert_argument_and_end_line($root);
+ = $self->_convert_argument_and_end_line($element);
if ($command eq '') {
$result .= "$arg$end_line";
} else {
@@ -748,7 +749,7 @@ sub _convert($$;$)
return '';
}
} elsif ($type eq 'skipline' or $type eq 'noarg') {
- if ($root->{'cmdname'} eq 'insertcopying') {
+ if ($element->{'cmdname'} eq 'insertcopying') {
if ($self->{'global_commands'}
and $self->{'global_commands'}->{'copying'}) {
return $self->_convert({'contents'
@@ -762,20 +763,20 @@ sub _convert($$;$)
} elsif ($type eq 'special' or $type eq 'skipspace') {
return '';
} elsif ($type eq 'lineraw') {
- if ($root->{'cmdname'} eq 'c' or $root->{'cmdname'} eq 'comment') {
- return $self->xml_comment($root->{'args'}->[0]->{'text'})
+ if ($element->{'cmdname'} eq 'c' or $element->{'cmdname'} eq
'comment') {
+ return $self->xml_comment($element->{'args'}->[0]->{'text'})
} else {
return "";
}
} else {
- $self->_bug_message("unknown misc_command style $type", $root)
+ $self->_bug_message("unknown misc_command style $type", $element)
if ($type !~ /^\d$/);
- if ($root->{'cmdname'} eq 'printindex') {
- if (defined($root->{'extra'})
- and defined($root->{'extra'}->{'misc_args'})) {
+ if ($element->{'cmdname'} eq 'printindex') {
+ if (defined($element->{'extra'})
+ and defined($element->{'extra'}->{'misc_args'})) {
# FIXME DocBook 5
- #return "<index
type=\"$root->{'extra'}->{'misc_args'}->[0]\"></index>\n";
- return "<index
role=\"$root->{'extra'}->{'misc_args'}->[0]\"></index>\n";
+ #return "<index
type=\"$element->{'extra'}->{'misc_args'}->[0]\"></index>\n";
+ return "<index
role=\"$element->{'extra'}->{'misc_args'}->[0]\"></index>\n";
} else {
return "<index></index>\n";
}
@@ -784,40 +785,40 @@ sub _convert($$;$)
}
}
- } elsif ($root->{'type'}
- and $root->{'type'} eq 'definfoenclose_command') {
+ } elsif ($element->{'type'}
+ and $element->{'type'} eq 'definfoenclose_command') {
my $in_monospace_not_normal;
- if (defined($default_args_code_style{$root->{'cmdname'}})
- and $default_args_code_style{$root->{'cmdname'}}->[0]) {
+ if (defined($default_args_code_style{$element->{'cmdname'}})
+ and $default_args_code_style{$element->{'cmdname'}}->[0]) {
$in_monospace_not_normal = 1;
- } elsif ($regular_font_style_commands{$root->{'cmdname'}}) {
+ } elsif ($regular_font_style_commands{$element->{'cmdname'}}) {
$in_monospace_not_normal = 0;
}
push @{$self->{'document_context'}->[-1]->{'monospace'}},
$in_monospace_not_normal
if (defined($in_monospace_not_normal));
- my $arg = $self->_convert($root->{'args'}->[0]);
- $result .= $self->xml_protect_text($root->{'extra'}->{'begin'}).$arg
- .$self->xml_protect_text($root->{'extra'}->{'end'});
+ my $arg = $self->_convert($element->{'args'}->[0]);
+ $result .= $self->xml_protect_text($element->{'extra'}->{'begin'}).$arg
+ .$self->xml_protect_text($element->{'extra'}->{'end'});
pop @{$self->{'document_context'}->[-1]->{'monospace'}}
if (defined($in_monospace_not_normal));
- } elsif ($root->{'args'}
- and exists($Texinfo::Common::brace_commands{$root->{'cmdname'}}))
{
- #debug_list (" brace command with args", $root->{'args'});
- if ($style_commands_formatting{$root->{'cmdname'}}) {
- if ($Texinfo::Common::context_brace_commands{$root->{'cmdname'}}) {
+ } elsif ($element->{'args'}
+ and
exists($Texinfo::Common::brace_commands{$element->{'cmdname'}})) {
+ #debug_list (" brace command with args", $element->{'args'});
+ if ($style_commands_formatting{$element->{'cmdname'}}) {
+ if ($Texinfo::Common::context_brace_commands{$element->{'cmdname'}}) {
push (@{$self->{'document_context'}},
{'monospace' => [0], 'upper_case' => [0]});
}
- my $formatting = $style_commands_formatting{$root->{'cmdname'}};
+ my $formatting = $style_commands_formatting{$element->{'cmdname'}};
my $in_monospace_not_normal;
- if (defined($default_args_code_style{$root->{'cmdname'}})
- and $default_args_code_style{$root->{'cmdname'}}->[0]) {
+ if (defined($default_args_code_style{$element->{'cmdname'}})
+ and $default_args_code_style{$element->{'cmdname'}}->[0]) {
$in_monospace_not_normal = 1;
- } elsif ($regular_font_style_commands{$root->{'cmdname'}}) {
+ } elsif ($regular_font_style_commands{$element->{'cmdname'}}) {
$in_monospace_not_normal = 0;
}
if ($formatting->{'upper_case'}) {
@@ -828,11 +829,11 @@ sub _convert($$;$)
if (defined($in_monospace_not_normal));
my ($style, $attribute_text) =
_parse_attribute($formatting->{'attribute'});
- my $result = $self->_convert($root->{'args'}->[0]);
+ my $result = $self->_convert($element->{'args'}->[0]);
if ($style ne '' and (!$self->{'document_context'}->[-1]->{'inline'}
or $inline_elements{$style})) {
$result = "<$style${attribute_text}>$result</$style>";
- if ($root->{'cmdname'} eq 'math') {
+ if ($element->{'cmdname'} eq 'math') {
$result = "<inlineequation>$result</inlineequation>";
}
}
@@ -845,36 +846,36 @@ sub _convert($$;$)
}
pop @{$self->{'document_context'}->[-1]->{'monospace'}}
if (defined($in_monospace_not_normal));
- if ($Texinfo::Common::context_brace_commands{$root->{'cmdname'}}) {
+ if ($Texinfo::Common::context_brace_commands{$element->{'cmdname'}}) {
pop @{$self->{'document_context'}};
}
- if ($root->{'cmdname'} eq 'w') {
+ if ($element->{'cmdname'} eq 'w') {
$result .= $w_command_mark;
}
return $result;
- } elsif ($root->{'cmdname'} eq 'anchor') {
- if ($root->{'extra'} and defined($root->{'extra'}->{'normalized'})) {
- return "<anchor id=\"$root->{'extra'}->{'normalized'}\"/>";
+ } elsif ($element->{'cmdname'} eq 'anchor') {
+ if ($element->{'extra'} and
defined($element->{'extra'}->{'normalized'})) {
+ return "<anchor id=\"$element->{'extra'}->{'normalized'}\"/>";
} else {
return '';
}
- } elsif ($Texinfo::Common::ref_commands{$root->{'cmdname'}}) {
- if ($root->{'args'}) {
- if ($root->{'cmdname'} eq 'inforef') {
+ } elsif ($Texinfo::Common::ref_commands{$element->{'cmdname'}}) {
+ if ($element->{'args'}) {
+ if ($element->{'cmdname'} eq 'inforef') {
my $filename;
- if (scalar(@{$root->{'args'}}) == 3
- and defined($root->{'args'}->[-1])
- and @{$root->{'args'}->[-1]->{'contents'}}) {
+ if (scalar(@{$element->{'args'}}) == 3
+ and defined($element->{'args'}->[-1])
+ and @{$element->{'args'}->[-1]->{'contents'}}) {
$filename =
$self->xml_protect_text(Texinfo::Convert::Text::convert_to_text(
- {'contents' => $root->{'args'}->[-1]->{'contents'}},
+ {'contents' => $element->{'args'}->[-1]->{'contents'}},
{'code' => 1,
Texinfo::Convert::Text::copy_options_for_convert_text($self)}));
}
my $node;
- if (defined($root->{'args'}->[0]) and
@{$root->{'args'}->[0]->{'contents'}}) {
+ if (defined($element->{'args'}->[0]) and
@{$element->{'args'}->[0]->{'contents'}}) {
$node = {'contents'
- => $root->{'args'}->[0]->{'contents'}};
+ => $element->{'args'}->[0]->{'contents'}};
}
if ($node and defined($filename)) {
return $self->_convert($self->gdt(
@@ -891,41 +892,41 @@ sub _convert($$;$)
{ 'myfile' => {'type' => '_converted', 'text' =>
$filename}}));
}
#my $name;
- #if (scalar(@{$root->{'args'}}) >= 2
- # and defined($root->{'args'}->[1]) and
@{$root->{'args'}->[1]->{'contents'}}) {
+ #if (scalar(@{$element->{'args'}}) >= 2
+ # and defined($element->{'args'}->[1]) and
@{$element->{'args'}->[1]->{'contents'}}) {
# $name = $self->_convert({'contents'
- # => $root->{'args'}->[0]->{'contents'}});
+ # => $element->{'args'}->[0]->{'contents'}});
#}
} else {
my $book_contents;
- if (scalar(@{$root->{'args'}}) == 5
- and defined($root->{'args'}->[-1]) and
@{$root->{'args'}->[-1]->{'contents'}}) {
- $book_contents = $root->{'args'}->[-1]->{'contents'};
+ if (scalar(@{$element->{'args'}}) == 5
+ and defined($element->{'args'}->[-1]) and
@{$element->{'args'}->[-1]->{'contents'}}) {
+ $book_contents = $element->{'args'}->[-1]->{'contents'};
}
my $manual_file_contents;
- if (scalar(@{$root->{'args'}}) >= 4
- and defined($root->{'args'}->[3]) and
@{$root->{'args'}->[3]->{'contents'}}) {
- $manual_file_contents = $root->{'args'}->[3]->{'contents'};
+ if (scalar(@{$element->{'args'}}) >= 4
+ and defined($element->{'args'}->[3]) and
@{$element->{'args'}->[3]->{'contents'}}) {
+ $manual_file_contents = $element->{'args'}->[3]->{'contents'};
}
my ($section_name_contents, $section_name);
- if (defined($root->{'args'}->[2]) and
@{$root->{'args'}->[2]->{'contents'}}) {
+ if (defined($element->{'args'}->[2]) and
@{$element->{'args'}->[2]->{'contents'}}) {
$section_name_contents
- = $root->{'args'}->[2]->{'contents'};
+ = $element->{'args'}->[2]->{'contents'};
$section_name = $self->_convert(
{'contents' => $section_name_contents});
- } elsif (defined($root->{'args'}->[1]) and
@{$root->{'args'}->[1]->{'contents'}}) {
+ } elsif (defined($element->{'args'}->[1]) and
@{$element->{'args'}->[1]->{'contents'}}) {
$section_name_contents
- = $root->{'args'}->[1]->{'contents'};
+ = $element->{'args'}->[1]->{'contents'};
$section_name = $self->_convert(
{'contents' => $section_name_contents});
- } elsif (defined($root->{'args'}->[0]) and
@{$root->{'args'}->[0]->{'contents'}}) {
+ } elsif (defined($element->{'args'}->[0]) and
@{$element->{'args'}->[0]->{'contents'}}) {
$section_name_contents
- = $root->{'args'}->[0]->{'contents'};
+ = $element->{'args'}->[0]->{'contents'};
$section_name = $self->_convert(
{'contents' => $section_name_contents});
if ($book_contents
- and
!$root->{'extra'}->{'node_argument'}->{'manual_content'}) {
+ and
!$element->{'extra'}->{'node_argument'}->{'manual_content'}) {
if ($section_name eq 'Top') {
$section_name = undef;
$section_name_contents = undef;
@@ -941,32 +942,32 @@ sub _convert($$;$)
if ($book_contents or $manual_file_contents) {
return '' if (!$book_contents);
if ($section_name_contents) {
- if ($root->{'cmdname'} eq 'ref') {
+ if ($element->{'cmdname'} eq 'ref') {
return $self->_convert(
$self->gdt('section ``{section_name}\'\' in @cite{{book}}',
{ 'section_name' => {'contents' =>
$section_name_contents},
'book' => $book_contents }));
- } elsif ($root->{'cmdname'} eq 'xref') {
+ } elsif ($element->{'cmdname'} eq 'xref') {
return $self->_convert(
$self->gdt('See section ``{section_name}\'\' in
@cite{{book}}',
{ 'section_name' => {'contents' =>
$section_name_contents},
'book' => $book_contents }));
- } elsif ($root->{'cmdname'} eq 'pxref') {
+ } elsif ($element->{'cmdname'} eq 'pxref') {
return $self->_convert(
$self->gdt('see section ``{section_name}\'\' in
@cite{{book}}',
{ 'section_name' => {'contents' =>
$section_name_contents},
'book' => $book_contents }));
}
} else {
- if ($root->{'cmdname'} eq 'ref') {
+ if ($element->{'cmdname'} eq 'ref') {
return $self->_convert(
$self->gdt('@cite{{book}}',
{'book' => $book_contents }));
- } elsif ($root->{'cmdname'} eq 'xref') {
+ } elsif ($element->{'cmdname'} eq 'xref') {
return $self->_convert(
$self->gdt('See @cite{{book}}',
{'book' => $book_contents }));
- } elsif ($root->{'cmdname'} eq 'pxref') {
+ } elsif ($element->{'cmdname'} eq 'pxref') {
return $self->_convert(
$self->gdt('see @cite{{book}}',
{'book' => $book_contents }));
@@ -974,23 +975,23 @@ sub _convert($$;$)
}
} else {
my $linkend = '';
- if ($root->{'extra'}->{'node_argument'}
- and
defined($root->{'extra'}->{'node_argument'}->{'normalized'})
- and
!$root->{'extra'}->{'node_argument'}->{'manual_content'}) {
- $linkend = "
linkend=\"$root->{'extra'}->{'node_argument'}->{'normalized'}\"";
+ if ($element->{'extra'}->{'node_argument'}
+ and
defined($element->{'extra'}->{'node_argument'}->{'normalized'})
+ and
!$element->{'extra'}->{'node_argument'}->{'manual_content'}) {
+ $linkend = "
linkend=\"$element->{'extra'}->{'node_argument'}->{'normalized'}\"";
}
my $argument = "<link${linkend}>".$section_name."</link>";
- if ($root->{'cmdname'} eq 'ref') {
+ if ($element->{'cmdname'} eq 'ref') {
return $self->_convert(
$self->gdt('{title_ref}', {'title_ref' =>
{'type' => '_converted',
'text' => $argument}}));
- } elsif ($root->{'cmdname'} eq 'xref') {
+ } elsif ($element->{'cmdname'} eq 'xref') {
return $self->_convert(
$self->gdt('See {title_ref}', {'title_ref' =>
{'type' => '_converted',
'text' => $argument}}));
- } elsif ($root->{'cmdname'} eq 'pxref') {
+ } elsif ($element->{'cmdname'} eq 'pxref') {
return $self->_convert(
$self->gdt('see {title_ref}', {'title_ref' =>
{'type' => '_converted',
@@ -1001,15 +1002,14 @@ sub _convert($$;$)
} else {
return '';
}
- } elsif ($root->{'cmdname'} eq 'image') {
- if (defined($root->{'args'}->[0])
- and @{$root->{'args'}->[0]->{'contents'}}) {
+ } elsif ($element->{'cmdname'} eq 'image') {
+ if (defined($element->{'args'}->[0])
+ and @{$element->{'args'}->[0]->{'contents'}}) {
my $basefile = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $root->{'args'}->[0]->{'contents'}},
+ {'contents' => $element->{'args'}->[0]->{'contents'}},
{'code' => 1,
Texinfo::Convert::Text::copy_options_for_convert_text($self)});
- my $element;
- my $is_inline = $self->_is_inline($root);
+ my $is_inline = $self->_is_inline($element);
if ($is_inline) {
$result .= "<inlinemediaobject>";
} else {
@@ -1030,7 +1030,7 @@ sub _convert($$;$)
.$self->xml_protect_text($file->[0])
."\" format=\"$file->[1]\"></imagedata></imageobject>";
}
- my ($image_text, $image_width) = $self->txt_image_text($root,
$basefile);
+ my ($image_text, $image_width) = $self->txt_image_text($element,
$basefile);
if (defined($image_text)) {
$result .= "<textobject><literallayout>"
.$self->_protect_text($image_text)
@@ -1039,7 +1039,7 @@ sub _convert($$;$)
if (!defined($image_text) and !$image_file_found) {
$self->line_warn($self, sprintf(
__("\@image file `%s' not found, using `%s'"),
- $basefile, "$basefile.jpg"), $root->{'line_nr'});
+ $basefile, "$basefile.jpg"), $element->{'line_nr'});
}
if ($is_inline) {
@@ -1048,18 +1048,18 @@ sub _convert($$;$)
$result .= "</mediaobject></informalfigure>";
}
}
- } elsif ($root->{'cmdname'} eq 'email') {
- if ($root->{'args'}) {
+ } elsif ($element->{'cmdname'} eq 'email') {
+ if ($element->{'args'}) {
my $name;
my $email;
my $email_text;
- if (scalar(@{$root->{'args'}}) == 2
- and defined($root->{'args'}->[-1])
- and @{$root->{'args'}->[-1]->{'contents'}}) {
- $name = $root->{'args'}->[1]->{'contents'};
+ if (scalar(@{$element->{'args'}}) == 2
+ and defined($element->{'args'}->[-1])
+ and @{$element->{'args'}->[-1]->{'contents'}}) {
+ $name = $element->{'args'}->[1]->{'contents'};
}
- if (defined($root->{'args'}->[0]) and
@{$root->{'args'}->[0]->{'contents'}}) {
- $email = $root->{'args'}->[0]->{'contents'};
+ if (defined($element->{'args'}->[0]) and
@{$element->{'args'}->[0]->{'contents'}}) {
+ $email = $element->{'args'}->[0]->{'contents'};
$email_text
= $self->_protect_text(Texinfo::Convert::Text::convert_to_text(
{'contents' => $email},
@@ -1078,12 +1078,12 @@ sub _convert($$;$)
return '';
}
- } elsif ($root->{'cmdname'} eq 'uref' or $root->{'cmdname'} eq 'url') {
- if ($root->{'args'}) {
+ } elsif ($element->{'cmdname'} eq 'uref' or $element->{'cmdname'} eq
'url') {
+ if ($element->{'args'}) {
my ($url_text, $url_content);
- if (defined($root->{'args'}->[0])
- and @{$root->{'args'}->[0]->{'contents'}}) {
- $url_content = $root->{'args'}->[0]->{'contents'};
+ if (defined($element->{'args'}->[0])
+ and @{$element->{'args'}->[0]->{'contents'}}) {
+ $url_content = $element->{'args'}->[0]->{'contents'};
$url_text = $self->_protect_text(
Texinfo::Convert::Text::convert_to_text(
{'contents' => $url_content},
@@ -1093,16 +1093,16 @@ sub _convert($$;$)
$url_text = '';
}
my $replacement;
- if (scalar(@{$root->{'args'}}) >= 2
- and defined($root->{'args'}->[1]) and
@{$root->{'args'}->[1]->{'contents'}}) {
+ if (scalar(@{$element->{'args'}}) >= 2
+ and defined($element->{'args'}->[1]) and
@{$element->{'args'}->[1]->{'contents'}}) {
$replacement = $self->_convert({'contents'
- => $root->{'args'}->[1]->{'contents'}});
+ => $element->{'args'}->[1]->{'contents'}});
}
if (!defined($replacement) or $replacement eq '') {
- if (scalar(@{$root->{'args'}}) == 3
- and defined($root->{'args'}->[2]) and
@{$root->{'args'}->[2]->{'contents'}}) {
+ if (scalar(@{$element->{'args'}}) == 3
+ and defined($element->{'args'}->[2]) and
@{$element->{'args'}->[2]->{'contents'}}) {
$replacement = $self->_convert({'contents'
- => $root->{'args'}->[2]->{'contents'}});
+ => $element->{'args'}->[2]->{'contents'}});
}
}
if (!defined($replacement) or $replacement eq '') {
@@ -1113,35 +1113,35 @@ sub _convert($$;$)
# return "<link xl:href=\"$url_text\">$replacement</link>";
}
- } elsif ($root->{'cmdname'} eq 'abbr' or $root->{'cmdname'} eq
'acronym') {
+ } elsif ($element->{'cmdname'} eq 'abbr' or $element->{'cmdname'} eq
'acronym') {
my $argument;
- if (scalar(@{$root->{'args'}}) >= 1
- and defined($root->{'args'}->[0]) and
@{$root->{'args'}->[0]->{'contents'}}) {
+ if (scalar(@{$element->{'args'}}) >= 1
+ and defined($element->{'args'}->[0]) and
@{$element->{'args'}->[0]->{'contents'}}) {
my $arg = $self->_convert({'contents'
- => $root->{'args'}->[0]->{'contents'}});
+ => $element->{'args'}->[0]->{'contents'}});
if ($arg ne '') {
- my $element;
- if ($root->{'cmdname'} eq 'abbr') {
- $element = 'abbrev';
+ my $format_element;
+ if ($element->{'cmdname'} eq 'abbr') {
+ $format_element = 'abbrev';
} else {
- $element = $root->{'cmdname'};
+ $format_element = $element->{'cmdname'};
}
- $argument = "<$element>$arg</$element>";
+ $argument = "<$format_element>$arg</$format_element>";
}
}
#
- if (scalar(@{$root->{'args'}}) == 2
- and defined($root->{'args'}->[-1]) and
@{$root->{'args'}->[-1]->{'contents'}}) {
+ if (scalar(@{$element->{'args'}}) == 2
+ and defined($element->{'args'}->[-1]) and
@{$element->{'args'}->[-1]->{'contents'}}) {
if (defined($argument)) {
my $tree = $self->gdt('{abbr_or_acronym} ({explanation})',
{'abbr_or_acronym' => {'type' => '_converted',
'text' => $argument},
'explanation' =>
- $root->{'args'}->[-1]->{'contents'}});
+ $element->{'args'}->[-1]->{'contents'}});
return $self->_convert($tree);
} else {
return $self->_convert({'contents'
- => $root->{'args'}->[-1]->{'contents'}});
+ => $element->{'args'}->[-1]->{'contents'}});
}
} elsif (defined($argument)) {
return $argument;
@@ -1149,52 +1149,52 @@ sub _convert($$;$)
return '';
}
- } elsif ($root->{'cmdname'} eq 'U') {
+ } elsif ($element->{'cmdname'} eq 'U') {
my $argument;
- if ($root->{'args'}
- and $root->{'args'}->[0]
- and $root->{'args'}->[0]->{'contents'}
- and $root->{'args'}->[0]->{'contents'}->[0]
- and $root->{'args'}->[0]->{'contents'}->[0]->{'text'}) {
- $argument = $root->{'args'}->[0]->{'contents'}->[0]->{'text'};
+ if ($element->{'args'}
+ and $element->{'args'}->[0]
+ and $element->{'args'}->[0]->{'contents'}
+ and $element->{'args'}->[0]->{'contents'}->[0]
+ and $element->{'args'}->[0]->{'contents'}->[0]->{'text'}) {
+ $argument = $element->{'args'}->[0]->{'contents'}->[0]->{'text'};
}
if ($argument) {
$result = "&#x$argument;";
} else {
$self->line_warn($self,
__("no argument specified for \@U"),
- $root->{'line_nr'});
+ $element->{'line_nr'});
$result = '';
}
return $result;
- } elsif ($Texinfo::Common::inline_commands{$root->{'cmdname'}}) {
+ } elsif ($Texinfo::Common::inline_commands{$element->{'cmdname'}}) {
my $expand = 0;
- if ($Texinfo::Common::inline_format_commands{$root->{'cmdname'}}) {
- if ($root->{'cmdname'} eq 'inlinefmtifelse'
- or ($root->{'extra'} and $root->{'extra'}->{'format'}
- and
$self->{'expanded_formats_hash'}->{$root->{'extra'}->{'format'}})) {
+ if ($Texinfo::Common::inline_format_commands{$element->{'cmdname'}}) {
+ if ($element->{'cmdname'} eq 'inlinefmtifelse'
+ or ($element->{'extra'} and $element->{'extra'}->{'format'}
+ and
$self->{'expanded_formats_hash'}->{$element->{'extra'}->{'format'}})) {
$expand = 1;
}
- } elsif (defined($root->{'extra'}->{'expand_index'})) {
+ } elsif (defined($element->{'extra'}->{'expand_index'})) {
$expand = 1;
}
return '' if (! $expand);
my $arg_index = 1;
- if ($root->{'cmdname'} eq 'inlineraw') {
+ if ($element->{'cmdname'} eq 'inlineraw') {
push @{$self->{'document_context'}}, {'monospace' => [0],
'upper_case' => [0]};
$self->{'document_context'}->[-1]->{'raw'} = 1;
- } elsif ($root->{'cmdname'} eq 'inlinefmtifelse'
- and !
$self->{'expanded_formats_hash'}->{$root->{'extra'}->{'format'}}) {
+ } elsif ($element->{'cmdname'} eq 'inlinefmtifelse'
+ and !
$self->{'expanded_formats_hash'}->{$element->{'extra'}->{'format'}}) {
$arg_index = 2;
}
- if (scalar(@{$root->{'args'}}) > $arg_index
- and defined($root->{'args'}->[$arg_index])
- and @{$root->{'args'}->[$arg_index]->{'contents'}}) {
+ if (scalar(@{$element->{'args'}}) > $arg_index
+ and defined($element->{'args'}->[$arg_index])
+ and @{$element->{'args'}->[$arg_index]->{'contents'}}) {
$result .= $self->_convert({'contents'
- => $root->{'args'}->[$arg_index]->{'contents'}});
+ => $element->{'args'}->[$arg_index]->{'contents'}});
}
- if ($root->{'cmdname'} eq 'inlineraw') {
+ if ($element->{'cmdname'} eq 'inlineraw') {
pop @{$self->{'document_context'}};
}
#warn " returning braced cmd result $result\n";
@@ -1207,28 +1207,28 @@ sub _convert($$;$)
# special case to ensure that @w leads to something even if empty
- } elsif ($root->{'cmdname'} eq 'w') {
+ } elsif ($element->{'cmdname'} eq 'w') {
return $w_command_mark;
- } elsif (exists($Texinfo::Common::block_commands{$root->{'cmdname'}})) {
- if ($self->{'context_block_commands'}->{$root->{'cmdname'}}) {
+ } elsif (exists($Texinfo::Common::block_commands{$element->{'cmdname'}})) {
+ if ($self->{'context_block_commands'}->{$element->{'cmdname'}}) {
push (@{$self->{'document_context'}},
{'monospace' => [0], 'upper_case' => [0]});
}
my @attributes;
my $appended = '';
- my @elements;
- if (exists($docbook_preformatted_formats{$root->{'cmdname'}})) {
+ my @format_elements;
+ if (exists($docbook_preformatted_formats{$element->{'cmdname'}})) {
push @{$self->{'document_context'}->[-1]->{'preformatted_stack'}},
- $docbook_preformatted_formats{$root->{'cmdname'}};
- } elsif ($root->{'cmdname'} eq 'enumerate') {
- push @elements, 'orderedlist';
+ $docbook_preformatted_formats{$element->{'cmdname'}};
+ } elsif ($element->{'cmdname'} eq 'enumerate') {
+ push @format_elements, 'orderedlist';
my $numeration;
- if ($root->{'extra'}
- and $root->{'extra'}->{'enumerate_specification'}) {
- if ($root->{'extra'}->{'enumerate_specification'} =~ /^[A-Z]/) {
+ if ($element->{'extra'}
+ and $element->{'extra'}->{'enumerate_specification'}) {
+ if ($element->{'extra'}->{'enumerate_specification'} =~ /^[A-Z]/) {
$numeration = 'upperalpha';
- } elsif ($root->{'extra'}->{'enumerate_specification'} =~ /^[a-z]/) {
+ } elsif ($element->{'extra'}->{'enumerate_specification'} =~
/^[a-z]/) {
$numeration = 'loweralpha';
} else {
$numeration = 'arabic';
@@ -1237,36 +1237,36 @@ sub _convert($$;$)
$numeration = 'arabic';
}
push @attributes, " numeration=\"$numeration\"";
- } elsif ($Texinfo::Common::item_line_commands{$root->{'cmdname'}}) {
- push @elements, 'variablelist';
- } elsif ($root->{'cmdname'} eq 'itemize') {
- push @elements, 'itemizedlist';
+ } elsif ($Texinfo::Common::item_line_commands{$element->{'cmdname'}}) {
+ push @format_elements, 'variablelist';
+ } elsif ($element->{'cmdname'} eq 'itemize') {
+ push @format_elements, 'itemizedlist';
#push @attributes, " mark=\"\"";
- } elsif ($root->{'cmdname'} eq 'multitable') {
- push @elements, "informaltable";
+ } elsif ($element->{'cmdname'} eq 'multitable') {
+ push @format_elements, "informaltable";
push @attributes, '';
my $columns_count;
- if ($root->{'extra'} and defined($root->{'extra'}->{'max_columns'})) {
- $columns_count = $root->{'extra'}->{'max_columns'};
+ if ($element->{'extra'} and
defined($element->{'extra'}->{'max_columns'})) {
+ $columns_count = $element->{'extra'}->{'max_columns'};
} else {
$columns_count = 0;
}
- push @elements, 'tgroup';
+ push @format_elements, 'tgroup';
push @attributes, " cols=\"$columns_count\"";
- if ($root->{'extra'}) {
+ if ($element->{'extra'}) {
my @fractions;
my $multiply;
- if ($root->{'extra'}->{'prototypes'}) {
+ if ($element->{'extra'}->{'prototypes'}) {
$multiply = 1;
- foreach my $prototype (@{$root->{'extra'}->{'prototypes'}}) {
+ foreach my $prototype (@{$element->{'extra'}->{'prototypes'}}) {
my $prototype_text
= Texinfo::Convert::Text::convert_to_text($prototype,
{Texinfo::Convert::Text::copy_options_for_convert_text($self)});
push @fractions,
Texinfo::Convert::Unicode::string_width($prototype_text);
}
- } elsif ($root->{'extra'}->{'columnfractions'}) {
- @fractions =
@{$root->{'extra'}->{'columnfractions'}->{'extra'}->{'misc_args'}};
+ } elsif ($element->{'extra'}->{'columnfractions'}) {
+ @fractions =
@{$element->{'extra'}->{'columnfractions'}->{'extra'}->{'misc_args'}};
$multiply = 100;
}
foreach my $fraction (@fractions) {
@@ -1274,24 +1274,24 @@ sub _convert($$;$)
.'*"></colspec>';
}
}
- } elsif ($root->{'cmdname'} eq 'float') {
- if ($root->{'extra'} and defined($root->{'extra'}->{'node_content'})) {
+ } elsif ($element->{'cmdname'} eq 'float') {
+ if ($element->{'extra'} and
defined($element->{'extra'}->{'node_content'})) {
my $normalized =
Texinfo::Convert::NodeNameNormalization::normalize_node (
- { 'contents' => $root->{'extra'}->{'node_content'} });
+ { 'contents' => $element->{'extra'}->{'node_content'} });
$result .= "<anchor id=\"$normalized\"/>\n";
}
- } elsif ($root->{'cmdname'} eq 'verbatim') {
- push @elements, 'screen';
- } elsif ($root->{'cmdname'} eq 'displaymath') {
- push @elements, 'informalequation';
- push @elements, 'mathphrase';
- } elsif ($root->{'cmdname'} eq 'quotation'
- or $root->{'cmdname'} eq 'smallquotation') {
- my $element;
- if ($root->{'extra'}) {
- if ($root->{'extra'}->{'authors'}) {
- foreach my $author (@{$root->{'extra'}->{'authors'}}) {
+ } elsif ($element->{'cmdname'} eq 'verbatim') {
+ push @format_elements, 'screen';
+ } elsif ($element->{'cmdname'} eq 'displaymath') {
+ push @format_elements, 'informalequation';
+ push @format_elements, 'mathphrase';
+ } elsif ($element->{'cmdname'} eq 'quotation'
+ or $element->{'cmdname'} eq 'smallquotation') {
+ my $format_element;
+ if ($element->{'extra'}) {
+ if ($element->{'extra'}->{'authors'}) {
+ foreach my $author (@{$element->{'extra'}->{'authors'}}) {
if ($author->{'extra'} and $author->{'args'}->[0]->{'contents'})
{
$appended .= '<attribution>'.$self->_convert(
{'contents' => $author->{'args'}->[0]->{'contents'}})
@@ -1299,42 +1299,42 @@ sub _convert($$;$)
}
}
}
- if ($root->{'args'} and $root->{'args'}->[0]
- and $root->{'args'}->[0]->{'contents'}
- and @{$root->{'args'}->[0]->{'contents'}}) {
+ if ($element->{'args'} and $element->{'args'}->[0]
+ and $element->{'args'}->[0]->{'contents'}
+ and @{$element->{'args'}->[0]->{'contents'}}) {
my $quotation_arg_text
= Texinfo::Convert::Text::convert_to_text(
- $root->{'args'}->[0],
+ $element->{'args'}->[0],
{Texinfo::Convert::Text::copy_options_for_convert_text($self)});
if ($docbook_special_quotations{lc($quotation_arg_text)}) {
- $element = lc($quotation_arg_text);
+ $format_element = lc($quotation_arg_text);
} else {
$self->{'pending_prepend'}
= $self->_convert($self->gdt('@b{{quotation_arg}:} ',
{'quotation_arg' =>
- $root->{'args'}->[0]->{'contents'}}));
+ $element->{'args'}->[0]->{'contents'}}));
}
}
}
- $element = 'blockquote' if (!defined($element));
- push @elements, $element;
- } elsif ($root->{'cmdname'} eq 'copying') {
- push @elements, ('bookinfo', 'legalnotice');
- } elsif ($Texinfo::Common::format_raw_commands{$root->{'cmdname'}}) {
- return '' if (!$self->{'expanded_formats_hash'}->{$root->{'cmdname'}});
+ $format_element = 'blockquote' if (!defined($format_element));
+ push @format_elements, $format_element;
+ } elsif ($element->{'cmdname'} eq 'copying') {
+ push @format_elements, ('bookinfo', 'legalnotice');
+ } elsif ($Texinfo::Common::format_raw_commands{$element->{'cmdname'}}) {
+ return '' if
(!$self->{'expanded_formats_hash'}->{$element->{'cmdname'}});
# the context is here only for the command, so this is forgotten
# once all the raw internal text has been formatted
$self->{'document_context'}->[-1]->{'raw'} = 1;
- } elsif ($Texinfo::Common::block_commands{$root->{'cmdname'}} eq 'raw') {
+ } elsif ($Texinfo::Common::block_commands{$element->{'cmdname'}} eq
'raw') {
return '';
- } elsif ($Texinfo::Common::menu_commands{$root->{'cmdname'}}) {
+ } elsif ($Texinfo::Common::menu_commands{$element->{'cmdname'}}) {
return '';
}
- foreach my $element (@elements) {
+ foreach my $format_element (@format_elements) {
my $attribute = shift @attributes;
$attribute = '' if (!defined($attribute));
- $result .= "<$element${attribute}>";
- unshift @close_elements, $element;
+ $result .= "<$format_element${attribute}>";
+ unshift @close_format_elements, $format_element;
}
$result .= $appended if (defined($appended));
}
@@ -1342,31 +1342,31 @@ sub _convert($$;$)
#warn " end of cmdname\n";
- if ($root->{'type'}) {
- #warn " have type $root->{'type'}\n";
- if (exists($docbook_preformatted_formats{$root->{'type'}})) {
+ if ($element->{'type'}) {
+ #warn " have type $element->{'type'}\n";
+ if (exists($docbook_preformatted_formats{$element->{'type'}})) {
push @{$self->{'document_context'}->[-1]->{'preformatted_stack'}},
- $docbook_preformatted_formats{$root->{'type'}};
+ $docbook_preformatted_formats{$element->{'type'}};
}
- if (defined($type_elements{$root->{'type'}})) {
- $result .= "<$type_elements{$root->{'type'}}>";
- } elsif ($root->{'type'} eq 'preformatted') {
+ if (defined($type_elements{$element->{'type'}})) {
+ $result .= "<$type_elements{$element->{'type'}}>";
+ } elsif ($element->{'type'} eq 'preformatted') {
$result .=
"<$self->{'document_context'}->[-1]->{'preformatted_stack'}->[-1]>";
$self->{'document_context'}->[-1]->{'in_preformatted'} = 1;
- } elsif ($root->{'type'} eq 'def_line') {
+ } elsif ($element->{'type'} eq 'def_line') {
$result .= "<synopsis>";
- $result .= $self->_index_entry($root);
+ $result .= $self->_index_entry($element);
push @{$self->{'document_context'}}, {'monospace' => [1], 'upper_case'
=> [0]};
$self->{'document_context'}->[-1]->{'inline'}++;
- if ($root->{'args'} and @{$root->{'args'}}
- and $root->{'args'}->[0]->{'contents'}) {
+ if ($element->{'args'} and @{$element->{'args'}}
+ and $element->{'args'}->[0]->{'contents'}) {
my $main_command;
- if ($Texinfo::Common::def_aliases{$root->{'extra'}->{'def_command'}}) {
- $main_command =
$Texinfo::Common::def_aliases{$root->{'extra'}->{'def_command'}};
+ if
($Texinfo::Common::def_aliases{$element->{'extra'}->{'def_command'}}) {
+ $main_command =
$Texinfo::Common::def_aliases{$element->{'extra'}->{'def_command'}};
} else {
- $main_command = $root->{'extra'}->{'def_command'};
+ $main_command = $element->{'extra'}->{'def_command'};
}
- foreach my $arg (@{$root->{'args'}->[0]->{'contents'}}) {
+ foreach my $arg (@{$element->{'args'}->[0]->{'contents'}}) {
next if $arg->{'type'}
and ($arg->{'type'} eq 'empty_spaces_after_command'
or $arg->{'type'} eq 'empty_line_after_command');
@@ -1400,92 +1400,92 @@ sub _convert($$;$)
}
}
- if ($root->{'contents'}) {
- #warn " have contents $root->{'contents'}\n";
+ if ($element->{'contents'}) {
+ #warn " have contents $element->{'contents'}\n";
my $in_code;
- if ($root->{'cmdname'}
- and ($Texinfo::Common::preformatted_code_commands{$root->{'cmdname'}}
- or $Texinfo::Common::math_commands{$root->{'cmdname'}})) {
+ if ($element->{'cmdname'}
+ and
($Texinfo::Common::preformatted_code_commands{$element->{'cmdname'}}
+ or $Texinfo::Common::math_commands{$element->{'cmdname'}})) {
$in_code = 1;
}
push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
if ($in_code);
- if (ref($root->{'contents'}) ne 'ARRAY') {
- cluck "contents not an array($root->{'contents'}).";
+ if (ref($element->{'contents'}) ne 'ARRAY') {
+ cluck "contents not an array($element->{'contents'}).";
}
- if (defined($self->{'pending_prepend'}) and $self->_in_inline($root)) {
+ if (defined($self->{'pending_prepend'}) and $self->_in_inline($element)) {
$result .= $self->{'pending_prepend'};
delete $self->{'pending_prepend'};
}
- foreach my $content (@{$root->{'contents'}}) {
+ foreach my $content (@{$element->{'contents'}}) {
$result .= $self->_convert($content);
}
pop @{$self->{'document_context'}->[-1]->{'monospace'}}
if ($in_code);
}
- if ($root->{'type'}) {
- if (defined($type_elements{$root->{'type'}})) {
- $result .= "</$type_elements{$root->{'type'}}>";
- } elsif ($root->{'type'} eq 'preformatted') {
+ if ($element->{'type'}) {
+ if (defined($type_elements{$element->{'type'}})) {
+ $result .= "</$type_elements{$element->{'type'}}>";
+ } elsif ($element->{'type'} eq 'preformatted') {
$result .=
"</$self->{'document_context'}->[-1]->{'preformatted_stack'}->[-1]>";
delete $self->{'document_context'}->[-1]->{'in_preformatted'};
}
}
$result = '{'.$result.'}'
- if ($root->{'type'} and $root->{'type'} eq 'bracketed'
- and (!$root->{'parent'}->{'type'} or
- ($root->{'parent'}->{'type'} ne 'block_line_arg'
- and $root->{'parent'}->{'type'} ne 'line_arg')));
- foreach my $element (@close_elements) {
- $result .= "</$element>";
+ if ($element->{'type'} and $element->{'type'} eq 'bracketed'
+ and (!$element->{'parent'}->{'type'} or
+ ($element->{'parent'}->{'type'} ne 'block_line_arg'
+ and $element->{'parent'}->{'type'} ne 'line_arg')));
+ foreach my $format_element (@close_format_elements) {
+ $result .= "</$format_element>";
}
- if ($root->{'cmdname'}
- and exists($Texinfo::Common::block_commands{$root->{'cmdname'}})) {
+ if ($element->{'cmdname'}
+ and exists($Texinfo::Common::block_commands{$element->{'cmdname'}})) {
# a pending_prepend still there may happen if a quotation is empty.
delete $self->{'pending_prepend'};
- #$result .= "</$root->{'cmdname'}>\n";
+ #$result .= "</$element->{'cmdname'}>\n";
if (!$self->{'document_context'}->[-1]->{'raw'}
- and exists($docbook_preformatted_formats{$root->{'cmdname'}})) {
+ and exists($docbook_preformatted_formats{$element->{'cmdname'}})) {
my $format = pop
@{$self->{'document_context'}->[-1]->{'preformatted_stack'}};
- die "BUG $format ne $docbook_preformatted_formats{$root->{'cmdname'}}"
- if ($format ne $docbook_preformatted_formats{$root->{'cmdname'}});
+ die "BUG $format ne $docbook_preformatted_formats{$element->{'cmdname'}}"
+ if ($format ne $docbook_preformatted_formats{$element->{'cmdname'}});
}
- if ($self->{'context_block_commands'}->{$root->{'cmdname'}}) {
+ if ($self->{'context_block_commands'}->{$element->{'cmdname'}}) {
pop @{$self->{'document_context'}};
}
- } elsif ($root->{'type'} and
exists($docbook_preformatted_formats{$root->{'type'}})) {
+ } elsif ($element->{'type'} and
exists($docbook_preformatted_formats{$element->{'type'}})) {
my $format = pop
@{$self->{'document_context'}->[-1]->{'preformatted_stack'}};
- die "BUG $format ne $docbook_preformatted_formats{$root->{'type'}}"
- if ($format ne $docbook_preformatted_formats{$root->{'type'}});
+ die "BUG $format ne $docbook_preformatted_formats{$element->{'type'}}"
+ if ($format ne $docbook_preformatted_formats{$element->{'type'}});
# The command is closed either when the corresponding tree element
# is done, and the command is not associated to an element, or when
# the element is closed.
- } elsif (($root->{'type'} and $root->{'type'} eq 'unit'
- and $root->{'extra'} and $root->{'extra'}->{'unit_command'})
- or ($root->{'cmdname'}
- and $Texinfo::Common::root_commands{$root->{'cmdname'}}
- and $root->{'cmdname'} ne 'node'
- and !($root->{'parent'} and $root->{'parent'}->{'type'}
- and $root->{'parent'}->{'type'} eq 'unit'
- and $root->{'parent'}->{'extra'}
- and $root->{'parent'}->{'extra'}->{'unit_command'} eq
$root))) {
- if ($root->{'type'} and $root->{'type'} eq 'unit') {
- $root = $root->{'extra'}->{'unit_command'};
+ } elsif (($element->{'type'} and $element->{'type'} eq 'unit'
+ and $element->{'extra'} and $element->{'extra'}->{'unit_command'})
+ or ($element->{'cmdname'}
+ and $Texinfo::Common::root_commands{$element->{'cmdname'}}
+ and $element->{'cmdname'} ne 'node'
+ and !($element->{'parent'} and $element->{'parent'}->{'type'}
+ and $element->{'parent'}->{'type'} eq 'unit'
+ and $element->{'parent'}->{'extra'}
+ and $element->{'parent'}->{'extra'}->{'unit_command'} eq
$element))) {
+ if ($element->{'type'} and $element->{'type'} eq 'unit') {
+ $element = $element->{'extra'}->{'unit_command'};
}
- my $command = $self->_docbook_section_element($root);
- if ($command eq 'part' and !Texinfo::Common::is_content_empty($root)) {
+ my $command = $self->_docbook_section_element($element);
+ if ($command eq 'part' and !Texinfo::Common::is_content_empty($element)) {
$result .= "</partintro>\n";
}
- my $command_texi = $self->_level_corrected_section($root);
- if (!($root->{'section_childs'} and scalar(@{$root->{'section_childs'}}))
+ my $command_texi = $self->_level_corrected_section($element);
+ if (!($element->{'section_childs'} and
scalar(@{$element->{'section_childs'}}))
or $command_texi eq 'top') {
$result .= "</$command>\n";
pop @{$self->{'lang_stack'}};
- my $current = $root;
+ my $current = $element;
while ($current->{'section_up'}
# the most up element is a virtual sectioning root element, this
# condition avoids getting into it
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * Texinfo/Convert/DocBook.pm: rename $root as $element if not a root element, and element as format_element for DocBook elements.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/Convert/HTML.pm (_html_get_tree_root_element) (command_filename, command_root_element_command) (_prepare_tree_root_elements): rename command_tree_unit_command() as command_root_element_command(), _html_get_tree_unit() as _html_get_tree_root_element(), rename _prepare_elements() as _prepare_tree_root_elements(), and use root_element as those functions deal with root elements, including special elements, not only tree unit elements.
- Next by Date:
branch master updated: * Texinfo/Convert/TexinfoXML.pm: rename $root as $element if not a root element, and element as format_element for TexinfoXML elements.
- Previous by thread:
branch master updated: * tp/Texinfo/Convert/HTML.pm (_html_get_tree_root_element) (command_filename, command_root_element_command) (_prepare_tree_root_elements): rename command_tree_unit_command() as command_root_element_command(), _html_get_tree_unit() as _html_get_tree_root_element(), rename _prepare_elements() as _prepare_tree_root_elements(), and use root_element as those functions deal with root elements, including special elements, not only tree unit elements.
- Next by thread:
branch master updated: * Texinfo/Convert/TexinfoXML.pm: rename $root as $element if not a root element, and element as format_element for TexinfoXML elements.
- Index(es):