On Thu, Nov 05, 2026 at 12:56:58AM +0000, Heime wrote:
> 
> I am using some conditions and get the warning: 
> 
> @end ifset should only appear at the beginning of a line
> 
> Can the conditionals be made to allow indentation.  Without indentation,
> the source is not very readable, particularly for nested blocks.

(switching to bug-texinfo).

I understand that in TeX, leading whitespace on a line is ignored.  I
double-checked that leading space before "@end ifset" works fine with TeX.

Patrice was opposed to copying TeX's handling of leading whitespace in
texi2any generally, but I see no reason why we couldn't allow whitespace
in this particular context.

I notice that there is no warning for @ifclear and @ifset which also 
have preceding spaces.  We may treat @ifset and @ifclear specially as
they are conditionals, but I tested with other commands including @chapter
and @table, and there were no warnings for these either.

In fact, the warning is only for @end ifset as the conditional is ignored.
There is no warning for "@end ifclear".

The warning comes from _process_raw_block_contents in Texinfo/ParserNonXS.pm
in Perl (presumably it's similar in the C code).  The regex to check for
the @end line explicitly allows leading space:

    } elsif ($line =~ /^(\s*?)\@end\s+([a-zA-Z][\w-]*)/
             and $2 eq $cmdname) {

(I had to lookup that "*?" is a "not greedy/minimal matching" modifier,
but in this context it would appear to be the same as "*".)

There is specific code to check for this leading space and give a warning.
It should be easy to remove the code for the warning:

diff --git a/tta/perl/Texinfo/ParserNonXS.pm b/tta/perl/Texinfo/ParserNonXS.pm
index 9673cefe30..eb53276ff8 100644
--- a/tta/perl/Texinfo/ParserNonXS.pm
+++ b/tta/perl/Texinfo/ParserNonXS.pm
@@ -7314,9 +7314,6 @@ sub _process_raw_block_contents($$) {
         if ($line =~ s/^(\s+)//) {
           push @{$current->{'contents'}},
             Texinfo::TreeElement::new({ 'text' => $1, 'type' => 'raw',});
-          _line_warn($self, sprintf(
-                __("\@end %s should only appear at the beginning of a line"),
-                                   $cmdname), $source_info);
         }
         print STDERR "CLOSED raw or ignored $cmdname\n"
                                      if ($self->{'conf'}->{'DEBUG'});


This would mean that @end in this one specific context was treated
similarly to other line commands.

Does this look OK?



> 
> ---
> 
> @table @asis
> 
> @item Edition
>   @value{TITLEPAGE-EDITION-NUMBER}
> 
> @item Sectioning
> 
>   @ifclear tsekn
>     Sequential Sectioning
>   @end ifclear
> 
>   @ifset tsekn
>     Tiered Sectioning
>   @end ifset
> 
> @end table
> 

Reply via email to