View Single Post
Old 03-04-2008, 08:46 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,438
Karma: 27757438
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Assuming the source file has an even number of quotes, shouldn't replacing them with curly quotes be as simple as

Code:
intag = False
inquote = False
for i, chr in enumerate(data):
  if chr == '<':
    intag = True
  elif chr == '>'
    intag = False
  elif not intag and chr == '"':
    if inquote:
      data[i] = right curly quote
      inquote = False
    else:
      data[i] = left curly quote
      inquote = True
Or is there something about curly quotes I'm missing?
kovidgoyal is offline   Reply With Quote