Smart quote character replacement for those with deficient sed-fu.

S

smitty1e

Use case:
=======
1. OSX 10.7, bunch of .tex files culled from a blog via some cruddy old Perl script.
..tex files are utf-8 encoded, which means the quotes and apostrophes drop out going through pdflatex.
2. Recommend using git to manage the .tex files, which are all in a /src directory in the project. If you're going to do batch edits, You Will Need tobranch, realize you gooned up, and roll back.
3. Understood, sed is the more classical tool here, except that I could notit to work in my OSX terminal.

Invocation:
=======
python charfix.py `ls src/*.tex`


charfix.py code:
=======
# -*- coding: utf-8 -*-
import fileinput

def process(line):
print line.replace( "’", "'" ).replace( "“", '"' ).replace( "”", '"' )

if __name__=="__main__":
for line in fileinput.input( inplace=1 ):
process(line)
=======

Discussion:
=======
Thank you, python!
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top