gnumed-devel
[Top][All Lists]
Advanced

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

Re: [Gnumed-devel] Latex failure


From: Karsten Hilbert
Subject: Re: [Gnumed-devel] Latex failure
Date: Sat, 1 Dec 2012 12:48:51 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, Dec 01, 2012 at 09:31:05AM +0100, Hilbert, Sebastian wrote:

> > > > {\small S} & {\small Follow up. Stool frequency 2/day. No blood.
> > > > Abdominal discomfort+, Fever + mild. Received crocin$\backslash$O2 with
> > > > relief} \tabularnewline> 
> > > What GNUmed does (did) is replace a literal "\" with the
> > > string "$\backslash$". "\backslash" is one way to say "print
> > > a \ here" in LaTeX. This command, however, only works in
> > > what's called Math Mode -- which is started and ended by "$"
> > > (which, in turn, is why "$" itself is a special LaTeX
> > > character and needs escaping if needed literally).
> > > 
> > > While GNUmed properly inserts "$\backslash$" still *another*
> > > layer goes over the content _again_ trying to escape special
> > > LaTeX chars inside data. This double-escaping is what's
> > > causing the trouble - it escapes the "$"s into "\$"s
> > > effectively disabling them from starting/ending Math Mode.
> > > 
> > > I will investigate where the double-escape comes from tomorrow.
> > 
> > Actually, it turned out not to be double-escaping but rather
> > a straightforward bug:
> > 
> >     def tex_escape_string(text=None):
> >             """check for special LaTeX characters and transform them"""
> > 
> >             text = text.replace(u'\\', u'$\\backslash$')
> >             text = text.replace(u'{', u'\\{')
> >             text = text.replace(u'}', u'\\}')
> >             text = text.replace(u'%', u'\\%')
> >             text = text.replace(u'&', u'\\&')
> >             text = text.replace(u'#', u'\\#')
> >             text = text.replace(u'$', u'\\$')
> >             text = text.replace(u'_', u'\\_')
> >             text = text.replace(u_euro, u'\\EUR')
> > 
> >             text = text.replace(u'^', u'\\verb#^#')
> >             text = text.replace('~','\\verb#~#')
> > 
> >             return text
> > 
> > This will *first* replace "\" with "$\backslash$" and *then*
> > replace "$" with "\$".
> > 
> > That can't work properly :-)
> > 
> > Fixed.
> > 
> > You may want to search your machine for the file
> > .../client/pycommon/gmTools.py, within that find the
> > function tex_escape_string and MOVE the line
> > 
> >     text = text.replace(u'\\', u'$\\backslash$')
> > 
> > AFTER the line
> > 
> >     text = text.replace(u'$', u'\\$')
> > 
> > That should do.
> > 
> 
> This will be fixed in the 1.2.x point release I think ?
> 
> I am currently extremely short on time but since there there are users 
> depending on this I will fix this for Ubuntu and Windows as soon as possible 
> (maybe tomorrow).

Hold on for a bit because the above fix does fix the issue
discussed but reintroduces the same issue backwards ;-)

I'll post a full fix later today.

Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



reply via email to

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