guile-user
[Top][All Lists]
Advanced

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

Re: string parsing/preparation for latex


From: Stephen Compall
Subject: Re: string parsing/preparation for latex
Date: Tue, 8 Nov 2005 10:56:08 -0600

David Pirotte writes: 
> but that is not possible, because the string (here simulated) 
> is a user typed in string  (through a gtk interface 
> programmed in guile-gnome) upon which I have no control. 
> I precisly wish to parse it to create a .tex file later 
> processed by latex ...

If you expect users to type in strings as Scheme expressions, I would
think you'd have no problem expecting them to know that backslashes have
to be escaped.

In other words, I think you're confusing reading strings, in the sense
of the `read' function for Scheme expressions, and reading raw character
data *into* strings, which is the usual practice when grabbing GUI form
fields, unless of course the form field is supposed to contain a Scheme
expression.

guile> (use-modules (ice-9 rdelim))
guile> (texu/prep-str-for-tex (read-line))
;; % \ { } ~ $ & # ^ _
=> ";; \\% \\\\ \\{ \\} \\~ \\$ \\& \\# \\^ \\_"
guile> (begin (display (texu/prep-str-for-tex (read-line))) (newline))
;; % \ { } ~ $ & # ^ _
-| ;; \% \\ \{ \} \~ \$ \& \# \^ \_

Where guile> is a prompt, => means a return value, -| means printed
line, all else is typed.

--
Stephen Compall
http://scompall.nocandysoftware.com/blog





reply via email to

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