[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Common.pm Texinfo/Convert/Do...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Common.pm Texinfo/Convert/Do... |
Date: |
Sat, 04 Aug 2012 20:08:03 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 12/08/04 20:08:02
Modified files:
tp/Texinfo : Common.pm
tp/Texinfo/Convert: DocBook.pm Info.pm Plaintext.pm XML.pm
tp/t/results/test_count: printindex.pl
Log message:
Handle monospace fonts using a stack. This will allow to switch back
and
forth to normal and monospace.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.144&r2=1.145
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Info.pm?cvsroot=texinfo&r1=1.85&r2=1.86
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.217&r2=1.218
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/test_count/printindex.pl?cvsroot=texinfo&r1=1.13&r2=1.14
Patches:
Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -b -r1.144 -r1.145
--- Texinfo/Common.pm 22 Jul 2012 22:32:43 -0000 1.144
+++ Texinfo/Common.pm 4 Aug 2012 20:08:02 -0000 1.145
@@ -462,15 +462,22 @@
}
our %style_commands;
-foreach my $style_command ('asis','b','cite','clicksequence',
+foreach my $style_command ('asis','cite','clicksequence',
'dfn', 'emph',
- 'i', 'sc', 't', 'r', 'slanted', 'sansserif', 'var',
+ 'sc', 't', 'var',
'headitemfont', 'code', 'command', 'env', 'file', 'kbd',
'option', 'samp', 'strong') {
$brace_commands{$style_command} = 1;
$style_commands{$style_command} = 1;
}
+our %regular_font_style_commands;
+foreach my $command ('r', 'i', 'b', 'sansserif', 'slanted') {
+ $regular_font_style_commands{$command} = 1;
+ $brace_commands{$command} = 1;
+ $style_commands{$command} = 1;
+}
+
foreach my $one_arg_command (
'ctrl','dmn', 'w', 'key',
'titlefont','hyphenation','anchor','errormsg') {
@@ -2142,6 +2149,11 @@
I<style_commands> that have their argument in code style, like
C<@code>.
+=item %regular_font_style_commands
+
+I<style_commands> that have their argument in regular font, like
+C<@r> or C<@slanted>.
+
=item %context_brace_commands
@-commands with brace like C<@footnote>, C<@caption> and C<@math>
Index: Texinfo/Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- Texinfo/Convert/DocBook.pm 3 Aug 2012 23:52:23 -0000 1.48
+++ Texinfo/Convert/DocBook.pm 4 Aug 2012 20:08:02 -0000 1.49
@@ -270,7 +270,7 @@
{
my $self = shift;
- $self->{'document_context'} = [{}];
+ $self->{'document_context'} = [{'monospace' => [0]}];
$self->{'context_block_commands'} = {%default_context_block_commands};
foreach my $raw (keys (%Texinfo::Common::format_raw_commands)) {
$self->{'context_block_commands'}->{$raw} = 1
@@ -382,8 +382,8 @@
my $index_entry = $root->{'extra'}->{'index_entry'};
# FIXME DocBook 5 role->type
my $result = "<indexterm role=\"$index_entry->{'index_name'}\"><primary>";
- push @{$self->{'document_context'}}, {};
- $self->{'document_context'}->[-1]->{'code'}++
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
+ $self->{'document_context'}->[-1]->{'monospace'}->[-1] = 1
if ($index_entry->{'in_code'});
$result .= $self->_convert({'contents' => $index_entry->{'content'}});
pop @{$self->{'document_context'}};
@@ -455,7 +455,7 @@
}
$result = $self->xml_protect_text($root->{'text'});
if (! defined($root->{'type'}) or $root->{'type'} ne 'raw') {
- if (!$self->{'document_context'}->[-1]->{'code'}) {
+ if (!$self->{'document_context'}->[-1]->{'monospace'}->[-1]) {
$result =~ s/``/$ldquo/g;
$result =~ s/\'\'/$rdquo/g;
$result =~ s/`/$lsquo/g;
@@ -547,9 +547,11 @@
if ($format_item_command
and defined($default_args_code_style{$format_item_command})
and $default_args_code_style{$format_item_command}->[0]);
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
$result .= $self->_convert($arg_tree);
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}}
+ if ($in_code);
chomp ($result);
$result .= "\n";
$result .= "</term>";
@@ -698,23 +700,26 @@
$in_code = 1
if (defined($default_args_code_style{$root->{'cmdname'}})
and $default_args_code_style{$root->{'cmdname'}}->[0]);
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
my $arg = $self->_convert($root->{'args'}->[0]);
$result .= $self->xml_protect_text($root->{'extra'}->{'begin'}).$arg
.$self->xml_protect_text($root->{'extra'}->{'end'});
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}}
+ if ($in_code);
} elsif ($root->{'args'}
and exists($Texinfo::Common::brace_commands{$root->{'cmdname'}}))
{
if ($style_commands_formatting{$root->{'cmdname'}}) {
if ($Texinfo::Common::context_brace_commands{$root->{'cmdname'}}) {
- push @{$self->{'document_context'}}, {};
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
}
my $formatting = $style_commands_formatting{$root->{'cmdname'}};
my $in_code;
$in_code = 1
if (defined($default_args_code_style{$root->{'cmdname'}})
and $default_args_code_style{$root->{'cmdname'}}->[0]);
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
my ($style, $attribute_text) =
_parse_attribute($formatting->{'attribute'});
my $result = $self->_convert($root->{'args'}->[0]);
if ($style ne '' and (!$self->{'document_context'}->[-1]->{'inline'}
@@ -728,7 +733,8 @@
$result = $self->get_conf('OPEN_QUOTE_SYMBOL') . $result
. $self->get_conf('CLOSE_QUOTE_SYMBOL');
}
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}}
+ if ($in_code);
if ($Texinfo::Common::context_brace_commands{$root->{'cmdname'}}) {
pop @{$self->{'document_context'}};
}
@@ -1011,7 +1017,7 @@
and $root->{'extra'} and $root->{'extra'}->{'format'}
and
$self->{'expanded_formats_hash'}->{$root->{'extra'}->{'format'}}) {
if ($root->{'cmdname'} eq 'inlineraw') {
- push @{$self->{'document_context'}}, {};
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
$self->{'document_context'}->[-1]->{'raw'} = 1;
}
if (scalar (@{$root->{'extra'}->{'brace_command_contents'}}) == 2
@@ -1032,7 +1038,7 @@
return $w_command_mark;
} elsif (exists($Texinfo::Common::block_commands{$root->{'cmdname'}})) {
if ($self->{'context_block_commands'}->{$root->{'cmdname'}}) {
- push @{$self->{'document_context'}}, {};
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
}
my @attributes;
my $appended = '';
@@ -1162,8 +1168,7 @@
} elsif ($root->{'type'} eq 'def_line') {
$result .= "<synopsis>";
$result .= $self->_index_entry($root);
- push @{$self->{'document_context'}}, {};
- $self->{'document_context'}->[-1]->{'code'}++;
+ push @{$self->{'document_context'}}, {'monospace' => [1]};
$self->{'document_context'}->[-1]->{'inline'}++;
if ($root->{'extra'} and $root->{'extra'}->{'def_args'}) {
my $main_command;
@@ -1205,7 +1210,8 @@
and $Texinfo::Common::preformatted_code_commands{$root->{'cmdname'}}) {
$in_code = 1;
}
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
if (ref($root->{'contents'}) ne 'ARRAY') {
cluck "contents not an array($root->{'contents'}).";
}
@@ -1216,7 +1222,8 @@
foreach my $content (@{$root->{'contents'}}) {
$result .= $self->_convert($content);
}
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}}
+ if ($in_code);
}
if ($root->{'type'}) {
if (defined($type_elements{$root->{'type'}})) {
Index: Texinfo/Convert/Info.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Info.pm,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- Texinfo/Convert/Info.pm 14 Jul 2012 23:20:08 -0000 1.85
+++ Texinfo/Convert/Info.pm 4 Aug 2012 20:08:02 -0000 1.86
@@ -235,7 +235,7 @@
$prefix = 'Ref';
}
push @{$self->{'count_context'}}, {'lines' => 0, 'bytes' => 0};
- my $label_text = _normalize_top_node($self->convert_line({'type' => 'code',
+ my $label_text = _normalize_top_node($self->convert_line({'type' =>
'_code',
'contents' => $label->{'root'}->{'extra'}->{'node_content'}}));
pop @{$self->{'count_context'}};
$tag_text .= "$prefix: $label_text\x{7F}$label->{'bytes'}\n";
@@ -373,7 +373,7 @@
my $node_begin = "\x{1F}\nFile: $output_filename, Node: ";
$result .= $node_begin;
$self->_add_text_count($node_begin);
- my $node_text = _normalize_top_node($self->convert_line({'type' => 'code',
+ my $node_text = _normalize_top_node($self->convert_line({'type' => '_code',
'contents' => $node->{'extra'}->{'node_content'}}));
$result .= $node_text;
foreach my $direction(@directions) {
@@ -383,13 +383,13 @@
$self->_add_text_count($text);
$result .= $text;
if ($node_direction->{'extra'}->{'manual_content'}) {
- $result .= $self->convert_line({'type' => 'code',
+ $result .= $self->convert_line({'type' => '_code',
'contents' => [{'text' => '('},
@{$node_direction->{'extra'}->{'manual_content'}},
{'text' => ')'}]});
}
if ($node_direction->{'extra'}->{'node_content'}) {
- $result .= _normalize_top_node($self->convert_line({'type' => 'code',
+ $result .= _normalize_top_node($self->convert_line({'type' => '_code',
'contents' => $node_direction->{'extra'}->{'node_content'}}));
}
}
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -b -r1.217 -r1.218
--- Texinfo/Convert/Plaintext.pm 31 Jul 2012 19:03:59 -0000 1.217
+++ Texinfo/Convert/Plaintext.pm 4 Aug 2012 20:08:02 -0000 1.218
@@ -136,7 +136,7 @@
# in container
# 'upper_case'
# 'var'
-# 'code'
+# 'font_type_stack'
#
# paragraph number incremented with paragraphs, center, listoffloats
# and block commands except: html and such, group, raggedright, menu*, float
@@ -267,7 +267,6 @@
# Quotes are reset in converter_initialize and unicode quotes are used
# if @documentencoding utf-8 is used.
foreach my $quoted_command (@quoted_commands) {
- #$style_map{$quoted_command} = ['`', "'"];
$style_map{$quoted_command} = ["'", "'"];
$quoted_code_commands{$quoted_command} = 1;
}
@@ -489,18 +488,25 @@
$text = uc($text);
}
# Even if in upper case, in code style or @var always end a sentence.
- if ($context->{'code'} or $context->{'var'}) {
+ if (#$context->{'code'}
+ $context->{'font_type_stack'}->[-1]->{'monospace'}
+ or $context->{'var'}) {
$lower_case_text = lc($text);
}
if ($self->get_conf('ENABLE_ENCODING') and $self->{'encoding_name'}
and $self->{'encoding_name'} eq 'utf-8') {
if (defined($lower_case_text)) {
$lower_case_text
- = Texinfo::Convert::Unicode::unicode_text($lower_case_text,
$context->{'code'});
- }
- return (Texinfo::Convert::Unicode::unicode_text($text, $context->{'code'}),
+ = Texinfo::Convert::Unicode::unicode_text($lower_case_text,
+ #$context->{'code'});
+ $context->{'font_type_stack'}->[-1]->{'monospace'});
+ }
+ return (Texinfo::Convert::Unicode::unicode_text($text,
+ $context->{'font_type_stack'}->[-1]->{'monospace'}),
+ #$context->{'code'}),
$lower_case_text);
- } elsif (!$context->{'code'}) {
+ #} elsif (!$context->{'code'}) {
+ } elsif (!$context->{'font_type_stack'}->[-1]->{'monospace'}) {
$text =~ s/---/\x{1F}/g;
$text =~ s/--/-/g;
$text =~ s/\x{1F}/--/g;
@@ -535,7 +541,8 @@
};
$container_conf->{'frenchspacing'} = 1
if ($self->get_conf('frenchspacing') eq 'on');
- $container_conf->{'counter'} =
$self->{'text_element_context'}->[-1]->{'counter'}
+ $container_conf->{'counter'}
+ = $self->{'text_element_context'}->[-1]->{'counter'}
if (defined($self->{'text_element_context'}->[-1]->{'counter'}));
$container_conf->{'DEBUG'} = 1 if ($self->get_conf('DEBUG'));
if ($conf) {
@@ -569,7 +576,9 @@
}
my $formatter = {'container' => $container, 'upper_case' => 0,
- 'code' => 0, 'code_command'=> 0, 'w' => 0, 'type' => $type,
+ #'code' => 0, 'code_command'=> 0,
+ 'font_type_stack' => [{}],
+ 'w' => 0, 'type' => $type,
'frenchspacing_stack' =>
[$self->get_conf('frenchspacing')]};
if ($type eq 'unfilled') {
@@ -578,8 +587,9 @@
last;
} elsif ($preformatted_code_commands{$context}
or $format_raw_commands{$context}) {
- $formatter->{'code'} = 1;
- $formatter->{'code_command'} = 1 if
($preformatted_code_commands{$context});
+ $formatter->{'font_type_stack'}->[-1]->{'monospace'} = 1;
+ $formatter->{'font_type_stack'}->[-1]->{'code_command'} = 1
+ if ($preformatted_code_commands{$context});
last;
}
}
@@ -608,7 +618,8 @@
my $converted = shift;
my $conf = shift;
my $formatter = $self->new_formatter('unfilled', $conf);
- $formatter->{'code'} = 1;
+ #$formatter->{'code'} = 1;
+ $formatter->{'font_type_stack'}->[-1]->{'monospace'} = 1;
push @{$self->{'formatters'}}, $formatter;
my $result = $self->_convert($converted);
$result .= $self->_count_added($formatter->{'container'},
@@ -1053,7 +1064,7 @@
next if ($ignored_entries{$entry});
my $entry_tree = {'contents' => $entry->{'content'}};
if ($entry->{'in_code'}) {
- $entry_tree->{'type'} = 'code';
+ $entry_tree->{'type'} = '_code';
} else {
$entry_tree->{'type'} = 'frenchspacing';
}
@@ -1100,7 +1111,7 @@
$self->{'index_entries_no_node'}->{$entry} = 1;
}
} else {
- $node_text = {'type' => 'code',
+ $node_text = {'type' => '_code',
'contents' => $node->{'extra'}->{'node_content'}};
}
$entry_line .= $self->convert_line($node_text);
@@ -1299,7 +1310,7 @@
#print STDERR " Special def_command: $root->{'extra'}->{'def_command'}\n"
# if (defined($root->{'extra'}) and $root->{'extra'}->{'def_command'});
if ($formatter) {
- print STDERR "
Container:($formatter->{'code'},$formatter->{'upper_case'},$formatter->{'frenchspacing_stack'}->[-1])
";
+ print STDERR "
Container:($formatter->{'font_type_stack'}->[-1]->{'monospace'},$formatter->{'upper_case'},$formatter->{'frenchspacing_stack'}->[-1])
";
$formatter->{'container'}->dump();
}
}
@@ -1466,7 +1477,8 @@
'sc' => $formatter->{'upper_case'}});
my $lower_case_text;
# always double spacing, so set underlying text lower case.
- if ($formatter->{'var'} or $formatter->{'code'}) {
+ if ($formatter->{'var'}
+ or $formatter->{'font_type_stack'}->[-1]->{'monospace'}) {
$lower_case_text = Texinfo::Convert::Text::brace_no_arg_command($root,
{%text_options,
'lc' => 1});
@@ -1517,7 +1529,8 @@
my $accented_text
= Texinfo::Convert::Text::text_accents($root, $encoding, $sc);
my $accented_text_lower_case;
- if ($formatter->{'var'} or $formatter->{'code'}) {
+ if ($formatter->{'var'}
+ or $formatter->{'font_type_stack'}->[-1]->{'monospace'}) {
$accented_text_lower_case
= Texinfo::Convert::Text::text_accents($root, $encoding, -1);
} elsif ($formatter->{'upper_case'}) {
@@ -1536,7 +1549,12 @@
} elsif ($self->{'style_map'}->{$command}
or ($root->{'type'} and $root->{'type'} eq 'definfoenclose_command'))
{
if ($code_style_commands{$command}) {
- $formatter->{'code'}++;
+ if (!$formatter->{'font_type_stack'}->[-1]->{'monospace'}) {
+ push @{$formatter->{'font_type_stack'}}, {'monospace' => 1};
+ } else {
+ $formatter->{'font_type_stack'}->[-1]->{'monospace'}++;
+ }
+ #$formatter->{'code'}++;
}
if ($no_punctation_munging_commands{$command}) {
push @{$formatter->{'frenchspacing_stack'}}, 'on';
@@ -1558,7 +1576,8 @@
$text_before = $root->{'extra'}->{'begin'};
$text_after = $root->{'extra'}->{'end'};
} else {
- if ($quoted_code_commands{$command} and $formatter->{'code_command'}) {
+ if ($quoted_code_commands{$command}
+ and $formatter->{'font_type_stack'}->[-1]->{'code_command'}) {
$text_before = '';
$text_after = '';
} else {
@@ -1569,7 +1588,7 @@
# do this after determining $text_before/$text_after such that it
# doesn't impact the current command, but only commands nested within
if ($quoted_code_commands{$command}) {
- $formatter->{'code_command'}++;
+ $formatter->{'font_type_stack'}->[-1]->{'code_command'}++;
}
$result .= $self->_count_added($formatter->{'container'},
$formatter->{'container'}->add_next($text_before,
@@ -1597,10 +1616,14 @@
if ($formatter->{'w'} == 0);
}
if ($code_style_commands{$command}) {
- $formatter->{'code'}--;
+ #$formatter->{'code'}--;
+ $formatter->{'font_type_stack'}->[-1]->{'monospace'}--;
+ pop @{$formatter->{'font_type_stack'}}
+ if !$formatter->{'font_type_stack'}->[-1]->{'monospace'};
}
if ($quoted_code_commands{$command}) {
- $formatter->{'code_command'}--;
+ #$formatter->{'code_command'}--;
+ $formatter->{'font_type_stack'}->[-1]->{'code_command'}--;
}
if ($no_punctation_munging_commands{$command}) {
pop @{$formatter->{'frenchspacing_stack'}};
@@ -1661,7 +1684,7 @@
{'contents' => $root->{'extra'}->{'brace_command_contents'}->[2]};
} elsif (defined($root->{'extra'}->{'brace_command_contents'}->[0])) {
# no mangling of --- and similar in url.
- my $url = {'type' => 'code',
+ my $url = {'type' => '_code',
'contents' => $root->{'extra'}->{'brace_command_contents'}->[0]};
if (scalar(@{$root->{'extra'}->{'brace_command_contents'}}) == 2
and defined($root->{'extra'}->{'brace_command_contents'}->[1])) {
@@ -1762,7 +1785,7 @@
my $file;
if (defined($args[3])) {
$file = [{'text' => '('},
- {'type' => 'code',
+ {'type' => '_code',
'contents' => $args[3]},
{'text' => ')'},];
} elsif (defined($args[4])) {
@@ -1777,13 +1800,13 @@
push @contents, @$file;
}
# node name
- push @contents, ({'type' => 'code',
+ push @contents, ({'type' => '_code',
'contents' => $node_content});
} else {
if ($file) {
push @contents, @$file;
}
- push @contents, ({'type' => 'code',
+ push @contents, ({'type' => '_code',
'contents' => address@hidden, {'text' => '::'}]});
}
$result = $self->_convert({'contents' => address@hidden);
@@ -1851,7 +1874,7 @@
and defined($root->{'extra'}->{'brace_command_contents'}->[-1])) {
my $argument;
if ($command eq 'inlineraw') {
- $argument->{'type'} = 'code';
+ $argument->{'type'} = '_code';
}
$argument->{'contents'}
= $root->{'extra'}->{'brace_command_contents'}->[-1];
@@ -1862,7 +1885,7 @@
push @{$self->{'context'}}, 'math';
if ($root->{'args'}) {
$result .= $self->_convert({'type' => 'frenchspacing',
- 'contents' => [{'type' => 'code',
+ 'contents' => [{'type' => '_code',
'contents' => [$root->{'args'}->[0]]}]});
}
my $old_context = pop @{$self->{'context'}};
@@ -2576,7 +2599,7 @@
'indent_length_next' =>
(1+$self->{'format_context'}->[-1]->{'indent_level'})*$indent_length});
push @{$self->{'formatters'}}, $def_paragraph;
- $result .= $self->_convert({'type' => 'code', 'contents' => [$tree]});
+ $result .= $self->_convert({'type' => '_code', 'contents' => [$tree]});
$result .= $self->_count_added($def_paragraph->{'container'},
$def_paragraph->{'container'}->end());
@@ -2597,7 +2620,7 @@
}
foreach my $arg (@{$root->{'args'}}) {
if ($arg->{'type'} eq 'menu_entry_node') {
- $result .= $self->_convert({'type' => 'code',
+ $result .= $self->_convert({'type' => '_code',
'contents' => $arg->{'contents'}});
} else {
$result .= $self->_convert($arg);
@@ -2610,8 +2633,13 @@
push @{$formatter->{'frenchspacing_stack'}}, 'on';
$formatter->{'container'}->set_space_protection(undef,
undef,undef,1);
- } elsif ($root->{'type'} eq 'code') {
- $formatter->{'code'}++;
+ } elsif ($root->{'type'} eq '_code') {
+ #$formatter->{'code'}++;
+ if (!$formatter->{'font_type_stack'}->[-1]->{'monospace'}) {
+ push @{$formatter->{'font_type_stack'}}, {'monospace' => 1};
+ } else {
+ $formatter->{'font_type_stack'}->[-1]->{'monospace'}++;
+ }
push @{$formatter->{'frenchspacing_stack'}}, 'on';
$formatter->{'container'}->set_space_protection(undef,
undef,undef,1);
@@ -2645,8 +2673,11 @@
$frenchspacing = 1 if ($formatter->{'frenchspacing_stack'}->[-1] eq
'on');
$formatter->{'container'}->set_space_protection(undef,
undef, undef, $frenchspacing);
- } elsif ($root->{'type'} eq 'code') {
- $formatter->{'code'}--;
+ } elsif ($root->{'type'} eq '_code') {
+ #$formatter->{'code'}--;
+ $formatter->{'font_type_stack'}->[-1]->{'monospace'}--;
+ pop @{$formatter->{'font_type_stack'}}
+ if !$formatter->{'font_type_stack'}->[-1]->{'monospace'};
pop @{$formatter->{'frenchspacing_stack'}};
my $frenchspacing = 0;
$frenchspacing = 1 if ($formatter->{'frenchspacing_stack'}->[-1] eq
'on');
Index: Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- Texinfo/Convert/XML.pm 3 Aug 2012 23:52:24 -0000 1.65
+++ Texinfo/Convert/XML.pm 4 Aug 2012 20:08:02 -0000 1.66
@@ -253,7 +253,7 @@
{
my $self = shift;
- $self->{'document_context'} = [{}];
+ $self->{'document_context'} = [{'monospace' => [0]}];
$self->{'context_block_commands'} = {%default_context_block_commands};
foreach my $raw (keys (%Texinfo::Common::format_raw_commands)) {
$self->{'context_block_commands'}->{$raw} = 1
@@ -311,8 +311,8 @@
if ($root->{'extra'} and $root->{'extra'}->{'index_entry'}) {
my $index_entry = $root->{'extra'}->{'index_entry'};
my $result = "<indexterm index=\"$index_entry->{'index_name'}\">";
- push @{$self->{'document_context'}}, {};
- $self->{'document_context'}->[-1]->{'code'}++
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
+ $self->{'document_context'}->[-1]->{'monospace'}->[-1] = 1
if ($index_entry->{'in_code'});
$result .= $self->_convert({'contents' => $index_entry->{'content'}});
pop @{$self->{'document_context'}};
@@ -406,7 +406,7 @@
}
$result = $self->xml_protect_text($root->{'text'});
if (! defined($root->{'type'}) or $root->{'type'} ne 'raw') {
- if (!$self->{'document_context'}->[-1]->{'code'}) {
+ if (!$self->{'document_context'}->[-1]->{'monospace'}->[-1]) {
$result =~ s/``/&textldquo;/g;
$result =~ s/\'\'/&textrdquo;/g;
$result =~ s/---/&textmdash;/g;
@@ -477,9 +477,10 @@
if ($format_item_command
and defined($default_args_code_style{$format_item_command})
and $default_args_code_style{$format_item_command}->[0]);
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
$result .= $self->_convert($root->{'args'}->[0]);
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}} if ($in_code);
chomp ($result);
if ($format_item_command) {
$result .= "</itemformat>";
@@ -541,7 +542,7 @@
$nodename = '';
}
$result .= "<node name=\"$nodename\">";
- $self->{'document_context'}->[-1]->{'code'}++;
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1;
$result .= "<nodename>".
$self->_convert({'contents' =>
$root->{'extra'}->{'node_content'}})
."</nodename>";
@@ -578,7 +579,7 @@
$end_line = "\n";
}
$result .= "</node>${end_line}";
- $self->{'document_context'}->[-1]->{'code'}--;
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}};
} elsif ($Texinfo::Common::root_commands{$root->{'cmdname'}}) {
my $attribute;
$command = $self->_level_corrected_section($root);
@@ -688,22 +689,23 @@
$in_code = 1
if (defined($default_args_code_style{$root->{'cmdname'}})
and $default_args_code_style{$root->{'cmdname'}}->[0]);
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
my $arg = $self->_convert($root->{'args'}->[0]);
$result .= "<infoenclose command=\"$root->{'cmdname'}\""
. $self->_infoenclose_attribute($root)
.">$arg</infoenclose>";
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}} if ($in_code);
} elsif ($root->{'args'}
and exists($Texinfo::Common::brace_commands{$root->{'cmdname'}}))
{
if ($Texinfo::Common::context_brace_commands{$root->{'cmdname'}}) {
- push @{$self->{'document_context'}}, {};
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
}
if ($Texinfo::Common::inline_format_commands{$root->{'cmdname'}}
and $root->{'extra'} and $root->{'extra'}->{'format'}
and
$self->{'expanded_formats_hash'}->{$root->{'extra'}->{'format'}}) {
if ($root->{'cmdname'} eq 'inlineraw') {
- push @{$self->{'document_context'}}, {};
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
$self->{'document_context'}->[-1]->{'raw'} = 1;
}
if (scalar (@{$root->{'extra'}->{'brace_command_contents'}}) == 2
@@ -741,13 +743,14 @@
$in_code = 1
if (defined($default_args_code_style{$root->{'cmdname'}})
and $default_args_code_style{$root->{'cmdname'}}->[$arg_index]);
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
my $arg = $self->_convert($root->{'args'}->[$arg_index]);
if (!defined($command) or $arg ne '') {
# ${attribute} is only set for @verb
$result .= "<$element${attribute}>$arg</$element>";
}
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}} if
($in_code);
} else {
last;
}
@@ -767,7 +770,7 @@
}
} elsif (exists($Texinfo::Common::block_commands{$root->{'cmdname'}})) {
if ($self->{'context_block_commands'}->{$root->{'cmdname'}}) {
- push @{$self->{'document_context'}}, {};
+ push @{$self->{'document_context'}}, {'monospace' => [0]};
}
my $prepended_elements = '';
my $attribute = '';
@@ -826,7 +829,8 @@
$in_code = 1
if (defined($default_args_code_style{$root->{'cmdname'}})
and
$default_args_code_style{$root->{'cmdname'}}->[$arg_index]);
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
my $arg;
if ($arg_index+1 eq scalar(@{$root->{'args'}})) {
# last argument
@@ -838,7 +842,8 @@
if ($arg ne '') {
$result .= "<$element>$arg</$element>";
}
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}}
+ if ($in_code);
} else {
last;
}
@@ -899,7 +904,7 @@
}
$result .= "<definitionterm>";
$result .= $self->_index_entry($root);
- $self->{'document_context'}->[-1]->{'code'}++;
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1;
if ($root->{'extra'} and $root->{'extra'}->{'def_args'}) {
my $main_command;
my $alias;
@@ -936,7 +941,7 @@
}
}
}
- $self->{'document_context'}->[-1]->{'code'}--;
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}};
$result .= "</definitionterm>";
if ($root->{'cmdname'}) {
$result .= "</$root->{'cmdname'}>";
@@ -951,14 +956,16 @@
and $Texinfo::Common::preformatted_code_commands{$root->{'cmdname'}}) {
$in_code = 1;
}
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
if (ref($root->{'contents'}) ne 'ARRAY') {
cluck "contents not an array($root->{'contents'}).";
}
foreach my $content (@{$root->{'contents'}}) {
$result .= $self->_convert($content);
}
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}}
+ if ($in_code);
}
if ($root->{'type'} and $root->{'type'} eq 'menu_entry') {
foreach my $arg (@{$root->{'args'}}) {
@@ -966,9 +973,11 @@
if ($arg->{'type'} eq 'menu_entry_node') {
$in_code = 1;
}
- $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1
+ if ($in_code);
$result .= $self->_convert($arg);
- $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}}
+ if ($in_code);
}
}
if ($root->{'type'}) {
Index: t/results/test_count/printindex.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/test_count/printindex.pl,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- t/results/test_count/printindex.pl 3 Dec 2011 14:58:40 -0000 1.13
+++ t/results/test_count/printindex.pl 4 Aug 2012 20:08:02 -0000 1.14
@@ -563,12 +563,12 @@
[2] (0,0) :text_root
[2] (0,0)
[3] (0,0) @node
- [4] (17,0) :code
+ [4] (17,0) :_code
[5] (17,0) :text|Top|
[5] (17,0)
locations (1) l 0 b 0
[4] (17,0)
- [6] (27,0) :code
+ [6] (27,0) :_code
[7] (27,0) :text|(|
[7] (27,0)
[8] (27,0) :text|dir|
@@ -594,7 +594,7 @@
[17] (55,6) :text|after index|
[17] (60,6)
[16] (60,6)
- [18] (96,6) :code
+ [18] (96,6) :_code
[19] (96,6) :text|Top|
[19] (96,6)
[18] (96,6)
@@ -602,7 +602,7 @@
[21] (128,7) :text|index entry|
[21] (133,7)
[20] (133,7)
- [22] (169,7) :code
+ [22] (169,7) :_code
[23] (169,7) :text|Top|
[23] (169,7)
[22] (169,7)
@@ -610,7 +610,7 @@
[25] (201,8) :text|index entry|
[25] (206,8)
[24] (206,8)
- [26] (242,8) :code
+ [26] (242,8) :_code
[27] (242,8) :text|Top|
[27] (242,8)
[26] (242,8)
@@ -618,7 +618,7 @@
[29] (274,9)
:text|looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong index
entry|
[29] (342,9)
[28] (342,9)
- [30] (352,9) :code
+ [30] (352,9) :_code
[31] (352,9) :text|Top|
[31] (352,9)
[30] (352,9)
@@ -635,7 +635,7 @@
[37] (452,15) :text|after index|
[37] (457,15)
[36] (457,15)
- [38] (493,15) :code
+ [38] (493,15) :_code
[39] (493,15) :text|Top|
[39] (493,15)
[38] (493,15)
@@ -643,7 +643,7 @@
[41] (525,16) :text|index entry|
[41] (530,16)
[40] (530,16)
- [42] (566,16) :code
+ [42] (566,16) :_code
[43] (566,16) :text|Top|
[43] (566,16)
[42] (566,16)
@@ -651,7 +651,7 @@
[45] (598,17) :text|index entry|
[45] (603,17)
[44] (603,17)
- [46] (639,17) :code
+ [46] (639,17) :_code
[47] (639,17) :text|Top|
[47] (639,17)
[46] (639,17)
@@ -659,7 +659,7 @@
[49] (671,18)
:text|looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong index
entry|
[49] (739,18)
[48] (739,18)
- [50] (749,18) :code
+ [50] (749,18) :_code
[51] (749,18) :text|Top|
[51] (749,18)
[50] (749,18)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Common.pm Texinfo/Convert/Do...,
Patrice Dumas <=