What is the best email quoting for blind users?

Tim Chase blinux.list at thechases.com
Thu Jun 1 14:31:06 UTC 2006

The below python script I cranked out will convert mail from the 
">" style of commenting to blocks marked by text (and for deeper 
levels, will note what level of quoting it is).

It can just be used as a filter, if your mailer supports it, as 
it reads from stdin and writes to stdout.

That way, if you need to convert the "usual" style of quoting to 
a more TTS-friendly style of quoting, this should automate the 
process for you.

Consider it public domain :)

Hope someone finds it useful,


#!/bin/env python
# By Tim Chase, June 2006
# Public Domain
from sys import stdin

# if you have more than one character that
# can be a leading quote character, you can just
# add it to this string.  E.g.
# QUOTECHAR = ">!#"
# will treat leading ">", "!", and "#" characters
# as quote-leaders.

def getLineQuoteDepth(line):
     depth = 0
     for char in line:
         if char in QUOTECHAR:
             depth += 1
         elif char != " ": break
     return depth

levels = []
for line in stdin:
     line = line.rstrip("\r\n")
     depth = getLineQuoteDepth(line)
     if depth:
         if levels and depth < levels[-1]:
             depth = levels[-1]
             del levels[-1]
             print "Ending quote",
             if depth > 1:
                 print "(level %i)" % levels[-1]
             else: print ""
         elif levels and depth == levels[-1]:
             print "Begining quote:",
             if depth > 1:
                 print "(level %i)" % levels[-1]
             else: print
         line = line.lstrip(QUOTECHAR + " ")
         if levels:
             del levels[-1]
             print "Ending quote"
     print line

More information about the Blinux-list mailing list