Subject: Texinfo: texi-fragment->stexi: Parsing verbatim fails when no newline

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

Hi,

When a "verbatim" fragment doesn't end in a newline character, parsing 
fails. This failure seems like a defect to me because it only happens 
with the "verbatim" command, and 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))
      (texi-fragment->stexi
       "Example:\n\n@verbatim\n(+ 3 5)\n@end verbatim")
    #+end_src

EXPECTED RESULT

I get the following stexi fragment:

#+begin_src scheme
   (*fragment* (para "Example:") (verbatim "(+ 3 5)\n"))
#+end_src

UNEXPECTED RESULT

I get the following error:

#+begin_example
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `parser-error' with args `(#<input: string 7f5fad5c02a0>
"EOF while reading a token " "reading verbatim")'.

In texinfo.scm:
   1132:22  5 (parse _)
    980:31  4 (loop #<input: string 7f5fad5c02a0> (*fragment*) _ _ _)
    890:16  3 (visit _ #<input: string 7f5fad5c02a0> _ _)
    537:20  2 (read-verbatim-body
               #<input: string 7f5fad5c02a0>
               #<procedure 7f5fad076948 at texinfo.scm:1069:3 (str…> …)
In sxml/ssax/input-parse.scm:
      88:2  1 (next-token _ _ _ _)
In ice-9/boot-9.scm:
   1685:16  0 (raise-exception _ #:continuable? _)
#+end_example

WORKAROUND

Append a newline character to the texi fragment, like so:

#+begin_src scheme
   (use-modules (texinfo))
   (texi-fragment->stexi
    "Example:\n\n@verbatim\n(+ 3 5)\n@end verbatim\n")
#+end_src

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