Subject: bug#62870: Texinfo: stexi->texi: Itemize End command not in a line of its own

From: Luis Felipe <[email-masked]>
Date: Sat, 15 Apr 2023 19:51:54 +0000

Hi,

The command ending an itemization (end command) is not placed in a line 
of its own, but it should:

"Block commands: These commands are written at the start of a line, with 
general text on following lines, terminated by a matching '@end' command 
on a line of its own." — Texinfo manual, @-Command Syntax.

This happens with the "itemize" command, but not with similar block 
commands like "example", "lisp", "display" and "format".

Operating system: Guix System x86_64 Kernel: 6.1.14-gnu
GNU Guile: 3.0.9

STEPS TO REPRODUCE

1. Start a Guile REPL
2. Run the following code:

    #+begin_src scheme
      (use-modules (texinfo serialize))
      (stexi->texi
       '(*fragment* (itemize (item "mango") (item "lemon"))))
    #+end_src

EXPECTED RESULT

A string like this one:

#+begin_src scheme
   "@itemize\n@item\nmango\n@item\nlemon\n@end itemize\n"
#+end_src

Which displays like this:

#+begin_example
@itemize
@item
mango
@item
lemon
@end itemize
#+end_example

UNEXPECTED RESULT

A string where the "@end itemize" command is not on a line of its own. 
Instead, the command gets appended to the last item in the list:

#+begin_src scheme
   "\n@c %start of fragment\n\n@itemize \n@item\nmango@item\nlemon@end 
itemize\n\n\n@c %end of fragment\n"
#+end_src

Which displays like this:

#+begin_example

@c %start of fragment

@itemize
@item
mango@item
lemon@end itemize

@c %end of fragment
#+end_example

Since the "@end" command is expected to be on a line of its own, tools 
like Texinfo's "makeinfo" program emit warnings like the following when 
converting the fragment to HTML:

#+begin_example
index.texi:73: warning: @end should only appear at the beginning of a line
#+end_example

(It seems also that the "items" themselves are not properly formatted, 
and, in addition, I wouldn't expect the wrapping comments about start 
and end of the fragment; but those seem like a different story, and 
don't trigger warnings anyways.)

WORKAROUND

Append a newline character to the last item of the list, like so:

#+begin_src scheme
   (use-modules (texinfo serialize))
   (stexi->texi
    '(*fragment* (itemize (item "mango") (item "lemon\n"))))
#+end_src

-- 
Luis Felipe López Acevedo
https://luis-felipe.gitlab.io/