bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no @image at start of paragraph


From: Gavin Smith
Subject: Re: no @image at start of paragraph
Date: Mon, 21 Dec 2015 20:28:40 +0000

On 21 December 2015 at 10:11, Patrice Dumas <address@hidden> wrote:
> The problem with such look-ahead with a regexp on the line is that it
> will miss expansion of @value or user-defined macros.  For example if we
> have something along
>
>  @macro mymacro
>      aaa
>  @end macro
>
>  @indent @mymacro{}
>
> The four spaces in the macro before aaa will be in the paragraph, though
> it should be outside (I believe).  In particular, this could potentially
> mess up Plaintext indenting.

You're right - I'm not surprised that there was some macro usage that
made this incorrect.

For reference, here's the code I wrote:

            if ($command eq 'indent'
                or $command eq 'noindent') {
              if ($line !~ /\n/) {
                my ($new_line, $new_line_nr) =
                  _new_line($self, $line_nr, undef);
                $line .= $new_line if (defined($new_line));
              }
              $line =~ s/^(\s*)//;

With the current revision, and the following input:


\input texinfo

@macro CC
         ccccccccc
@end macro

@noindent  @CC{} LLLLLl
dddddo

@bye

The following shows the parse tree that's created:

$./texi2any.pl ~/test.texi -c TEXINFO_OUTPUT_FORMAT=debugtree
text_root
 preamble
  preamble_text |\input texinfo\n|
  preamble_text |\n|
 @macro
  %macro_name |CC|
  raw |         ccccccccc|
  last_raw_newline |\n|
 empty_line_after_command |\n|
 empty_line |\n|
 @noindent
 empty_spaces_after_command |  |
 paragraph
  |         ccccccccc LLLLLl\n|
  |dddddo\n|
 empty_line |\n|
 @bye
  %misc_arg |\n|

So as you say, the spaces in the macro are being viewed as part of the
paragraph. The output looks OK:

$cat test.info
This is test.info, produced by texi2any version 6.0.90+dev from
test.texi.

ccccccccc LLLLLl dddddo



Tag Table:

End Tag Table

I don't see how this could mess up the indenting, because (as far as I
know) a command like @code, which makes every space count, isn't
allowed outside of a paragraph, and if you try something like

@noindent @address@hidden

the @code gets in the way of the spaces of the user-defined macro.

Consistency with TeX and texinfo.tex is a concern. TeX has a
complicated way of reading its input. Spaces after control sequences
are skipped (depending on the context). That's why the spaces after
@indent are ignored in TeX. Control sequences that follow aren't
involved in this space skipping though, even if they expand to
starting with spaces. TeX's complicated because "input" and
"expansion" are two separate stages with their own rules.

I believe texi2any can skip spaces between a command taking arguments
in braces and the opening brace: it's the same process in TeX, so
however it's done should maybe be how it's done for @noindent and
@indent.

I concocted the following input file to show the issue:

\input texinfo

@macro A

@end macro

@code @A{} {arg}

@code    {arg}

@bye

This macro @A consists of two spaces. When processed with texi2any,
the two output lines are identical:

This is test2.info, produced by texi2any version 6.0.90+dev from
test2.texi.

'arg'

   'arg'



Tag Table:

End Tag Table

As you see, both lines are surrounded by quotation marks to mark them
as code. However, when processed as TeX, only the second line is in a
monospaced typewriter font. In the TeX output the argument to @code
isn't "code", it's "@A".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]