Python LaTeX codec?

D

David Eppstein

Does anyone have an implemented Python codec for converting between
unicode and LaTeX markup? E.g. I'd like 'ï' to be converted to '{\"\i}'
and vice versa. Preferably including at least the Latin Extended-A
characters as well as the basic Latin-1 Supplement.

If not, anyone with experience writing Python codecs have any advice on
how to do this?
 
K

Karl M Syring

David Eppstein wrote on Tue, 14 Oct 2003 08:27:09 -0700:
Does anyone have an implemented Python codec for converting between
unicode and LaTeX markup? E.g. I'd like 'ï' to be converted to '{\"\i}'
and vice versa. Preferably including at least the Latin Extended-A
characters as well as the basic Latin-1 Supplement.

If not, anyone with experience writing Python codecs have any advice on
how to do this?

There is Recodec
http://www.iro.umontreal.ca/~pinard/recodec/
which may fit the bill.

Karl M. Syring
 
W

William Park

In said:
Does anyone have an implemented Python codec for converting between
unicode and LaTeX markup? E.g. I'd like '?' to be converted to '{\"\i}'
and vice versa. Preferably including at least the Latin Extended-A
characters as well as the basic Latin-1 Supplement.

If not, anyone with experience writing Python codecs have any advice on
how to do this?

For heaven's sake,
man tr
man sed
man awk
man bash
 
N

netnews.upenn.edu

William said:
For heaven's sake,
man tr
man sed
man awk
man bash


Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\>man tr
'man' is not recognized as an internal or external command,
operable program or batch file.

C:\>man sed
'man' is not recognized as an internal or external command,
operable program or batch file.

C:\>man awk
'man' is not recognized as an internal or external command,
operable program or batch file.

C:\>man bash
'man' is not recognized as an internal or external command,
operable program or batch file.

.....and for good measure...

C:\>help sed
This command is not supported by the help utility. Try "sed /?".

....ducking and running.....

Yes, I have cygwin on my windows boxes and I've got Linux/BSD boxen,
etc. but the sort of kneejerk reaction to use the standard unix command
line tools isn't very helpful. What if the OP wanted to distribute his
program to users whom were unlikely to have access to such a tool chain?

Pointing out that there are some pre-existing tools can be useful, but
the "for heaven's sake" approach doesn't really help to address the
posters question about a _Python_ codec.... (one of the other responses
mentioning "recodec" does...)

--Paul
 
D

David Eppstein

"netnews.upenn.edu said:
William said:
For heaven's sake,
man tr
man sed
man awk
man bash


Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

I am using a Mac, so Windows not having these isn't a problem.

But, Park's response doesn't really address my question at all.
For one thing, there was a reason I asked for this as Python code, which
is that I want to use this as a subroutine of a larger application, and
don't want the expense of firing up a separate program every time I want
to use this subroutine. More importantly, the difficult part is not so
much actually performing the conversion (whether by one of these
programs or more cleanly as a pure Python codec), but in coming up with
the tables of patterns to be converted.
 
N

netnews.upenn.edu

David said:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.


I am using a Mac, so Windows not having these isn't a problem.

But, Park's response doesn't really address my question at all.
For one thing, there was a reason I asked for this as Python code, which
is that I want to use this as a subroutine of a larger application, and

That was essentially the point of the rest of my post -- the quoted unix
tools weren't universal and that you had asked for Python code. I used
Windows as an example because that was the box I was sitting at when I
read the post.

Actually, I think many (all?) of those tools may be available by default
if you're using OS X, but I'm too lazy to fire up my powerbook at the
moment...

--Paul
 
P

Patrick TJ McPhee

%
% >>
% >>
% >>Microsoft Windows 2000 [Version 5.00.2195]
% >>(C) Copyright 1985-2000 Microsoft Corp.
% >
% >
% > I am using a Mac, so Windows not having these isn't a problem.
% >
% > But, Park's response doesn't really address my question at all.
% > For one thing, there was a reason I asked for this as Python code, which
% > is that I want to use this as a subroutine of a larger application, and
%
% That was essentially the point of the rest of my post -- the quoted unix
% tools weren't universal and that you had asked for Python code. I used
% Windows as an example because that was the box I was sitting at when I
% read the post.
%
% Actually, I think many (all?) of those tools may be available by default
% if you're using OS X, but I'm too lazy to fire up my powerbook at the
% moment...

The tools are universal, or at least as universal as any other tools,
although most people with unix toolkits don't bother installing the
man command, but none of the man pages would help with the problem,
and only one of the tools (either sed or awk) would be helpful in
implementing a solution. It's certainly not a `for Heaven's sake'
question.

recode, on the other hand, will do exactly what the OP wants, and it's
table driven. If python has a class with similar functionality, I'd be
surprised if all the recode tables aren't available for it.
 
A

Alexander Schmolck

David Eppstein said:
Does anyone have an implemented Python codec for converting between
unicode and LaTeX markup? E.g. I'd like 'ï' to be converted to '{\"\i}'
and vice versa. Preferably including at least the Latin Extended-A
characters as well as the basic Latin-1 Supplement.

there is some xml markup'ed unicode<->latex chart

http://www.bitjungle.com/~isoent/

I've written python code to extract the information, which I'll send you if
you want (some time ago, can't remember how complete it was).

'as
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top