[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string parsing/preparation for latex
From: |
Jose Roberto B. de A. Monteiro |
Subject: |
Re: string parsing/preparation for latex |
Date: |
Tue, 08 Nov 2005 14:35:44 -0200 |
Em Ter, 2005-11-08 às 15:52 +0100, David Pirotte escreveu:
> On Mon, 07 Nov 2005 13:49:01 -0200
> "Jose Roberto B. de A. Monteiro" <address@hidden> wrote:
>
> > Em Seg, 2005-11-07 às 14:53 +0100, David Pirotte escreveu:
> > > does anyone understands why this does not return the expected result
> > >
> > > (define *texu/reserved-characters*
> > > ;; % \ { } ~ $ & # ^ _
> > > '(
> > > #\% ;; comments
> > > #\\ ;; command(follows by a space)
> > > #\{ ;; definition of treatment block(main_arg)
> > > #\}
> > > #\~ ;; indivisible space
> > > #\$ ;; mathematical mode
> > > #\& ;; tabulation ...
> > > #\# ;; symbol of parameter zone
> > > #\^ ;; exponent
> > > #\_ ;; index
> > > )
> > > )
> > >
> > > (define (texu/prep-str-for-tex str)
> > > (let ((str-lst (string->list str))
> > > (result (list)))
> > > (for-each (lambda (chr)
> > > (if (member chr *texu/reserved-characters*)
> > > (set! result (cons chr (cons #\\ result)))
> > > (set! result (cons chr result))))
> > > str-lst)
> > > (reverse-list->string result)
> > > ))
> >
> > Because you should have this string: ";; % \\ { } ~ $ & # ^ _", with two
> > backslashes instead of one... the same for "
>
> 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 ...
Ok, look at the foloowing:
guile> (define s ";; % \\ { } ~ $ & # ^ _")
We need the double backslash here to define one backslash in the
internal string code. Then:
guile> s
";; % \\ { } ~ $ & # ^ _"
guile> (texu/prep-str-for-tex s)
";; \\% \\\\ \\{ \\} \\~ \\$ \\& \\# \\^ \\_"
Well, I believe that your code is working properly. Each pair of '\' is
in reality one '\'...
- string parsing/preparation for latex, David Pirotte, 2005/11/07
- Re: string parsing/preparation for latex, Jose Roberto B. de A. Monteiro, 2005/11/07
- Re: string parsing/preparation for latex, Jon Wilson, 2005/11/07
- Re: string parsing/preparation for latex, David Pirotte, 2005/11/08
- Re: string parsing/preparation for latex, Jon Wilson, 2005/11/08
- Re: string parsing/preparation for latex, klaus schilling, 2005/11/09
- Re: string parsing/preparation for latex, Jon Wilson, 2005/11/09
- Re: string parsing/preparation for latex, Stephen Compall, 2005/11/13
- Re: string parsing/preparation for latex, Jon Wilson, 2005/11/14
- Re: string parsing/preparation for latex, Stephen Compall, 2005/11/15