Karim Belabas on Sat, 19 Jul 2008 02:17:50 +0200


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

Re: No newline in addhelp


* John Gerdeman [2008-07-18 20:23]:
> I'm documenting some functions I wrote using addhelp, but addhelp does
> not seem to understand, i.e just ignores it completely, the newline
> sequence \n. On the other hand the tab sequence \t seems to be
> understood just fine.
> 
> Is there a way to force addhelp to give out a newline? It seems like one
> of the basic things text structure.

It's an old limitation in a badly written function (I'm responsible for
this one).

The routine used to "print help text" writes word by word, wrapping long
lines and ignoring multiple consecutive spaces (as LaTeX or an HTML
browser would for instance). Unfortunately the notion of "word" was
"separated by whitespace of newline". So newlines are ignored (treated
as space), while tabs are printed verbatim since they are "word"
characters (and don't split words).

Bad.

Since it doesn't make sense not to treat tabs as whitespace, and since
it can actually be useful to include explicit newlines (paragraphs)
in a long help text, I have fixed this in current svn.

* multiple (ordinary) spaces are still treated as 1 single space.
* a tab is now recognized as a word separator
* a newline provokes an immediate line break
* multiple tabs or newlines are echoed as they were written, according
to their multiplicity:

(02:13) gp > addhelp(fun, "A\n\tsimple\n\n\t\tsilly         test")
time = 0 ms.
(02:13) gp > ?fun
A
        simple

                silly test

(02:13) gp >


Thanks for pointing this out,

    K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]
`