[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp TODO Texinfo/Convert/DocBook.pm Texi...
From: |
Patrice Dumas |
Subject: |
texinfo/tp TODO Texinfo/Convert/DocBook.pm Texi... |
Date: |
Wed, 14 Sep 2011 22:59:13 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/09/14 22:59:13
Modified files:
tp : TODO
tp/Texinfo/Convert: DocBook.pm XML.pm
tp/t : xml_tests.t
Added files:
tp/t/results/xml_tests: raw.pl
Log message:
Handle better raw xml/docbook.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.168&r2=1.169
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/xml_tests.t?cvsroot=texinfo&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/xml_tests/raw.pl?cvsroot=texinfo&rev=1.1
Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -b -r1.168 -r1.169
--- TODO 13 Sep 2011 23:09:47 -0000 1.168
+++ TODO 14 Sep 2011 22:59:13 -0000 1.169
@@ -2,6 +2,23 @@
perl -w t/02coverage.t -o
xmllint --nonet --noout --valid commands.xml
+xml_tests/raw
+
+ Para
+ @xml
+ <in>
+ @end xml
+
+leads to
+
+ <para>Para
+ <in>
+ </para>
+
+should be
+ <para>Para
+ <in></para>
+
@appendix should stop @part. Right now it do not do that.
Cf sectioning_part_appendix.
Index: Texinfo/Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Texinfo/Convert/DocBook.pm 12 Sep 2011 23:39:14 -0000 1.4
+++ Texinfo/Convert/DocBook.pm 14 Sep 2011 22:59:13 -0000 1.5
@@ -516,9 +516,15 @@
return '' if ($root->{'type'} and $ignored_types{$root->{'type'}});
my $result = '';
if (defined($root->{'text'})) {
- return $root->{'text'} if ((defined($root->{'type'})
- and $root->{'type'} eq '_converted')
- or $self->{'document_context'}->[-1]->{'raw'});
+ if (defined($root->{'type'}) and $root->{'type'} eq '_converted') {
+ return $root->{'text'};
+ } elsif ($self->{'document_context'}->[-1]->{'raw'}) {
+ if ($root->{'type'} and $root->{'type'} eq 'empty_line_after_command') {
+ return '';
+ } else {
+ return $root->{'text'};
+ }
+ }
$result = $self->xml_protect_text($root->{'text'});
if (! defined($root->{'type'}) or $root->{'type'} ne 'raw') {
if (!$self->{'document_context'}->[-1]->{'code'}) {
@@ -1106,7 +1112,7 @@
} elsif ($Texinfo::Common::block_commands{$root->{'cmdname'}} eq 'raw') {
return '' if (!$self->{'expanded_formats_hash'}->{$root->{'cmdname'}});
if ($root->{'cmdname'} eq 'docbook') {
- # the context ids here only for the command, so this is forgotten
+ # the context is here only for the command, so this is forgotten
# once al the raw internal text has been formatted
$self->{'document_context'}->[-1]->{'raw'} = 1;
}
@@ -1198,12 +1204,17 @@
if ($root->{'cmdname'}
and exists($Texinfo::Common::block_commands{$root->{'cmdname'}})) {
#$result .= "</$root->{'cmdname'}>\n";
+ if ($self->{'document_context'}->[-1]->{'raw'}) {
+ chomp ($result);
+ chomp ($result);
+ } else {
$result .= "\n";
if (exists($docbook_preformatted_formats{$root->{'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'}});
}
+ }
if ($context_block_commands{$root->{'cmdname'}}) {
pop @{$self->{'document_context'}};
}
Index: Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- Texinfo/Convert/XML.pm 13 Sep 2011 23:09:47 -0000 1.32
+++ Texinfo/Convert/XML.pm 14 Sep 2011 22:59:13 -0000 1.33
@@ -88,8 +88,8 @@
'bullet' => '•',
'copyright' => '©right;',
'registeredsymbol' => '®istered;',
- 'dots' => '&dots',
- 'enddots' => '&enddots',
+ 'dots' => '&dots;',
+ 'enddots' => '&enddots;',
'error' => '&errorglyph;',
'expansion' => '&expansion;',
'arrow' => '→',
@@ -132,7 +132,7 @@
'setfilename' => 'file',
'documentencoding' => 'encoding',
'verbatiminclude' => 'file',
- 'documentlanguage' => 'language',
+ 'documentlanguage' => 'xml:lang',
);
# FIXME printindex is special?
@@ -232,6 +232,7 @@
my %context_block_commands = (
'float' => 1,
+ 'xml' => 1,
);
sub _defaults($)
@@ -393,6 +394,14 @@
return '' if ($root->{'type'} and $ignored_types{$root->{'type'}});
my $result = '';
if (defined($root->{'text'})) {
+ if ($self->{'document_context'}->[-1]->{'raw'}) {
+ # ignore the newline at the end of the @xml line
+ if ($root->{'type'} and $root->{'type'} eq 'empty_line_after_command') {
+ return '';
+ } else {
+ return $root->{'text'};
+ }
+ }
$result = $self->xml_protect_text($root->{'text'});
if (! defined($root->{'type'}) or $root->{'type'} ne 'raw') {
if (!$self->{'document_context'}->[-1]->{'code'}) {
@@ -737,6 +746,10 @@
} elsif ($root->{'cmdname'} eq 'verbatim') {
$attribute = " xml:space=\"preserve\"";
}
+ if ($self->{'expanded_formats_hash'}->{$root->{'cmdname'}}
+ and $root->{'cmdname'} eq 'xml') {
+ $self->{'document_context'}->[-1]->{'raw'} = 1;
+ } else {
$result .= "<$root->{'cmdname'}${attribute}>";
my $end_line = '';
if ($root->{'args'}) {
@@ -804,6 +817,7 @@
unshift @close_elements, $root->{'cmdname'};
}
}
+ }
if ($root->{'type'}) {
if (defined($type_elements{$root->{'type'}})) {
my $attribute;
@@ -848,7 +862,7 @@
$element = $defcommand_name_type{$main_command};
} elsif ($type eq 'arg') {
$element = 'param';
- } elsif ($type eq 'argtype') {
+ } elsif ($type eq 'typearg') {
$element = 'paramtype';
} else {
$element = $type;
@@ -911,6 +925,11 @@
# FIXME The end of line and comment is taken into account
# but 'space_at_end' is ignored.
my $end_command = $root->{'extra'}->{'end_command'};
+ if ($self->{'expanded_formats_hash'}->{$root->{'cmdname'}}
+ and $root->{'cmdname'} eq 'xml') {
+ chomp ($result);
+ chomp ($result);
+ } else {
my $end_line;
if ($end_command) {
$end_line
@@ -921,6 +940,7 @@
$end_line = "\n";
}
$result .= $end_line;
+ }
if ($context_block_commands{$root->{'cmdname'}}) {
pop @{$self->{'document_context'}};
}
Index: t/xml_tests.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/xml_tests.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- t/xml_tests.t 6 Sep 2011 23:04:03 -0000 1.2
+++ t/xml_tests.t 14 Sep 2011 22:59:13 -0000 1.3
@@ -120,6 +120,16 @@
@end raggedright
'],
+['raw',
+'@tex
+in <tex>
address@hidden tex
+
+Para
address@hidden
+<in>
address@hidden xml
+'],
);
foreach my $test (@test_cases) {
Index: t/results/xml_tests/raw.pl
===================================================================
RCS file: t/results/xml_tests/raw.pl
diff -N t/results/xml_tests/raw.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/xml_tests/raw.pl 14 Sep 2011 22:59:13 -0000 1.1
@@ -0,0 +1,146 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text);
+
+use utf8;
+
+$result_trees{'raw'} = {
+ 'contents' => [
+ {
+ 'cmdname' => 'tex',
+ 'contents' => [
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'in <tex>
+',
+ 'type' => 'raw'
+ }
+ ],
+ 'extra' => {},
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'Para
+'
+ },
+ {
+ 'cmdname' => 'xml',
+ 'contents' => [
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => '<in>
+',
+ 'type' => 'raw'
+ }
+ ],
+ 'extra' => {},
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 6,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'raw'}{'contents'}[0]{'contents'}[0]{'extra'}{'command'} =
$result_trees{'raw'}{'contents'}[0];
+$result_trees{'raw'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'raw'}{'contents'}[0];
+$result_trees{'raw'}{'contents'}[0]{'contents'}[1]{'parent'} =
$result_trees{'raw'}{'contents'}[0];
+$result_trees{'raw'}{'contents'}[0]{'parent'} = $result_trees{'raw'};
+$result_trees{'raw'}{'contents'}[1]{'extra'}{'command'} =
$result_trees{'raw'}{'contents'}[0];
+$result_trees{'raw'}{'contents'}[1]{'parent'} = $result_trees{'raw'};
+$result_trees{'raw'}{'contents'}[2]{'parent'} = $result_trees{'raw'};
+$result_trees{'raw'}{'contents'}[3]{'contents'}[0]{'parent'} =
$result_trees{'raw'}{'contents'}[3];
+$result_trees{'raw'}{'contents'}[3]{'contents'}[1]{'contents'}[0]{'extra'}{'command'}
= $result_trees{'raw'}{'contents'}[3]{'contents'}[1];
+$result_trees{'raw'}{'contents'}[3]{'contents'}[1]{'contents'}[0]{'parent'} =
$result_trees{'raw'}{'contents'}[3]{'contents'}[1];
+$result_trees{'raw'}{'contents'}[3]{'contents'}[1]{'contents'}[1]{'parent'} =
$result_trees{'raw'}{'contents'}[3]{'contents'}[1];
+$result_trees{'raw'}{'contents'}[3]{'contents'}[1]{'parent'} =
$result_trees{'raw'}{'contents'}[3];
+$result_trees{'raw'}{'contents'}[3]{'contents'}[2]{'extra'}{'command'} =
$result_trees{'raw'}{'contents'}[3]{'contents'}[1];
+$result_trees{'raw'}{'contents'}[3]{'contents'}[2]{'parent'} =
$result_trees{'raw'}{'contents'}[3];
+$result_trees{'raw'}{'contents'}[3]{'parent'} = $result_trees{'raw'};
+
+$result_texis{'raw'} = '@tex
+in <tex>
address@hidden tex
+
+Para
address@hidden
+<in>
address@hidden xml
+';
+
+
+$result_texts{'raw'} = '
+Para
+';
+
+$result_errors{'raw'} = [];
+
+
+
+$result_converted{'xml'}->{'raw'} = '<tex>
+in <tex>
+</tex>
+
+
+<para>Para
+<in>
+</para>';
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp TODO Texinfo/Convert/DocBook.pm Texi...,
Patrice Dumas <=