[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Common.pm Texinfo/Parser.pm ...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Common.pm Texinfo/Parser.pm ... |
Date: |
Fri, 17 Aug 2012 23:39:55 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 12/08/17 23:39:55
Modified files:
tp/Texinfo : Common.pm Parser.pm
tp/t : 60macro.t
Added files:
tp/t/results/macro: leading_spaces_ignore.pl
leading_spaces_no_ignore.pl
Log message:
Add IGNORE_LEADING_SPACE_IN_MACRO_BODY customization variable to remove
leading spaces in macrobody.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.150&r2=1.151
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.385&r2=1.386
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/60macro.t?cvsroot=texinfo&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/leading_spaces_ignore.pl?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/leading_spaces_no_ignore.pl?cvsroot=texinfo&rev=1.1
Patches:
Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -b -r1.150 -r1.151
--- Texinfo/Common.pm 14 Aug 2012 07:38:21 -0000 1.150
+++ Texinfo/Common.pm 17 Aug 2012 23:39:54 -0000 1.151
@@ -188,6 +188,7 @@
'TREE_TRANSFORMATIONS', 'BASEFILENAME_LENGTH',
# FIXME document
'TEXTCONTENT_COMMENT', 'XREF_USE_FLOAT_LABEL', 'XREF_USE_NODE_NAME_ARG',
+ 'IGNORE_LEADING_SPACE_IN_MACRO_BODY'
);
# Not strings.
# FIXME To be documented somewhere, but where?
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.385
retrieving revision 1.386
diff -u -b -r1.385 -r1.386
--- Texinfo/Parser.pm 11 Aug 2012 23:47:17 -0000 1.385
+++ Texinfo/Parser.pm 17 Aug 2012 23:39:55 -0000 1.386
@@ -109,6 +109,7 @@
'include_directories' => [ '.' ],
'INLINE_INSERTCOPYING' => 0,
'IGNORE_BEFORE_SETFILENAME' => 1,
+ 'IGNORE_LEADING_SPACE_IN_MACRO_BODY' => 0,
# this is the initial context. It is put at the bottom of the
# 'context_stack'
'context' => '_root',
@@ -2477,6 +2478,16 @@
}
}
+sub _strip_macrobody_leading_space($$)
+{
+ my $self = shift;
+ my $text = shift;
+ if ($self->{'IGNORE_LEADING_SPACE_IN_MACRO_BODY'}) {
+ $text =~ s/^\s*//mg;
+ }
+ return $text;
+}
+
# close constructs and do stuff at end of line (or end of the document)
sub _end_line($$$);
sub _end_line($$$)
@@ -3155,7 +3166,8 @@
$self->{'macros'}->{'insertcopying'} = {
'args' => [{'text' => 'insertcopying', 'type' =>
'macro_name'}],
'cmdname' => 'macro',
- 'extra' => {'macrobody' => $body}
+ 'extra' => {'macrobody' =>
+ $self->_strip_macrobody_leading_space($body)}
};
$inline_copying = 1;
print STDERR "INLINE_INSERTCOPYING as macro\n" if
($self->{'DEBUG'});
@@ -3615,8 +3627,9 @@
or ($current->{'parent'}->{'cmdname'} ne 'macro'
and $current->{'parent'}->{'cmdname'} ne 'rmacro'))) {
$current->{'extra'}->{'macrobody'} =
+ $self->_strip_macrobody_leading_space(
Texinfo::Convert::Texinfo::convert({ 'contents'
- => $current->{'contents'} });
+ => $current->{'contents'} }));
if ($current->{'args'} and $current->{'args'}->[0]) {
my $name = $current->{'args'}->[0]->{'text'};
if (exists($self->{'macros'}->{$name})) {
@@ -5436,6 +5449,10 @@
is put in a special container type, @C<preamble_before_setfilename>.
This option is set in the default case.
+=item IGNORE_LEADING_SPACE_IN_MACRO_BODY
+
+If set, leading spaces are stripped from user defined macro bodies.
+
=item MAX_MACRO_CALL_NESTING
Maximal number of nested user-defined macro calls. Default is 100000.
Index: t/60macro.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/60macro.t,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- t/60macro.t 19 Jul 2012 11:46:35 -0000 1.40
+++ t/60macro.t 17 Aug 2012 23:39:55 -0000 1.41
@@ -931,6 +931,22 @@
@code{code}
'],
+['leading_spaces_no_ignore',
+'@macro mymacro
+ Some here
+ text
address@hidden macro
+
address@hidden
+'],
+['leading_spaces_ignore',
+'@macro mymacro
+ Some here
+ text
address@hidden macro
+
address@hidden
+', {'IGNORE_LEADING_SPACE_IN_MACRO_BODY' => 1}],
);
my @todo =(
Index: t/results/macro/leading_spaces_ignore.pl
===================================================================
RCS file: t/results/macro/leading_spaces_ignore.pl
diff -N t/results/macro/leading_spaces_ignore.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/macro/leading_spaces_ignore.pl 17 Aug 2012 23:39:55 -0000
1.1
@@ -0,0 +1,116 @@
+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{'leading_spaces_ignore'} = {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'parent' => {},
+ 'text' => 'mymacro',
+ 'type' => 'macro_name'
+ }
+ ],
+ 'cmdname' => 'macro',
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => ' Some here
+',
+ 'type' => 'raw'
+ },
+ {
+ 'parent' => {},
+ 'text' => ' text',
+ 'type' => 'raw'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'last_raw_newline'
+ }
+ ],
+ 'extra' => {
+ 'arg_line' => ' mymacro
+',
+ 'macrobody' => 'Some here
+text
+'
+ },
+ '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' => 'Some here
+'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'text
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'leading_spaces_ignore'}{'contents'}[0]{'args'}[0]{'parent'} =
$result_trees{'leading_spaces_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_ignore'}{'contents'}[0]{'contents'}[0]{'parent'}
= $result_trees{'leading_spaces_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_ignore'}{'contents'}[0]{'contents'}[1]{'parent'}
= $result_trees{'leading_spaces_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_ignore'}{'contents'}[0]{'contents'}[2]{'parent'}
= $result_trees{'leading_spaces_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_ignore'}{'contents'}[0]{'parent'} =
$result_trees{'leading_spaces_ignore'};
+$result_trees{'leading_spaces_ignore'}{'contents'}[1]{'extra'}{'command'} =
$result_trees{'leading_spaces_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_ignore'}{'contents'}[1]{'parent'} =
$result_trees{'leading_spaces_ignore'};
+$result_trees{'leading_spaces_ignore'}{'contents'}[2]{'parent'} =
$result_trees{'leading_spaces_ignore'};
+$result_trees{'leading_spaces_ignore'}{'contents'}[3]{'contents'}[0]{'parent'}
= $result_trees{'leading_spaces_ignore'}{'contents'}[3];
+$result_trees{'leading_spaces_ignore'}{'contents'}[3]{'contents'}[1]{'parent'}
= $result_trees{'leading_spaces_ignore'}{'contents'}[3];
+$result_trees{'leading_spaces_ignore'}{'contents'}[3]{'parent'} =
$result_trees{'leading_spaces_ignore'};
+
+$result_texis{'leading_spaces_ignore'} = '@macro mymacro
+ Some here
+ text
address@hidden macro
+
+Some here
+text
+';
+
+
+$result_texts{'leading_spaces_ignore'} = '
+Some here
+text
+';
+
+$result_errors{'leading_spaces_ignore'} = [];
+
+
+1;
Index: t/results/macro/leading_spaces_no_ignore.pl
===================================================================
RCS file: t/results/macro/leading_spaces_no_ignore.pl
diff -N t/results/macro/leading_spaces_no_ignore.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/macro/leading_spaces_no_ignore.pl 17 Aug 2012 23:39:55 -0000
1.1
@@ -0,0 +1,122 @@
+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{'leading_spaces_no_ignore'} = {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'parent' => {},
+ 'text' => 'mymacro',
+ 'type' => 'macro_name'
+ }
+ ],
+ 'cmdname' => 'macro',
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => ' Some here
+',
+ 'type' => 'raw'
+ },
+ {
+ 'parent' => {},
+ 'text' => ' text',
+ 'type' => 'raw'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'last_raw_newline'
+ }
+ ],
+ 'extra' => {
+ 'arg_line' => ' mymacro
+',
+ 'macrobody' => ' Some here
+ text
+'
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'parent' => {},
+ 'text' => ' ',
+ 'type' => 'empty_spaces_before_paragraph'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'Some here
+'
+ },
+ {
+ 'parent' => {},
+ 'text' => ' text
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[0]{'args'}[0]{'parent'}
= $result_trees{'leading_spaces_no_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[0]{'contents'}[0]{'parent'}
= $result_trees{'leading_spaces_no_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[0]{'contents'}[1]{'parent'}
= $result_trees{'leading_spaces_no_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[0]{'contents'}[2]{'parent'}
= $result_trees{'leading_spaces_no_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[0]{'parent'} =
$result_trees{'leading_spaces_no_ignore'};
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[1]{'extra'}{'command'} =
$result_trees{'leading_spaces_no_ignore'}{'contents'}[0];
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[1]{'parent'} =
$result_trees{'leading_spaces_no_ignore'};
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[2]{'parent'} =
$result_trees{'leading_spaces_no_ignore'};
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[3]{'parent'} =
$result_trees{'leading_spaces_no_ignore'};
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[4]{'contents'}[0]{'parent'}
= $result_trees{'leading_spaces_no_ignore'}{'contents'}[4];
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[4]{'contents'}[1]{'parent'}
= $result_trees{'leading_spaces_no_ignore'}{'contents'}[4];
+$result_trees{'leading_spaces_no_ignore'}{'contents'}[4]{'parent'} =
$result_trees{'leading_spaces_no_ignore'};
+
+$result_texis{'leading_spaces_no_ignore'} = '@macro mymacro
+ Some here
+ text
address@hidden macro
+
+ Some here
+ text
+';
+
+
+$result_texts{'leading_spaces_no_ignore'} = '
+Some here
+ text
+';
+
+$result_errors{'leading_spaces_no_ignore'} = [];
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Common.pm Texinfo/Parser.pm ...,
Patrice Dumas <=