Simon Josefsson writes: >> '>' may appear at the beginning of a line accidently, and we certainly >> want to supply the space character in this case. > > First, wouldn't it be very complicated to solve your case? No, I don't think so. I think it helps to consider a leading '>' to be a quote character only if the preceding line is empty (or consists entirely of whitespace), or if it starts in turn with a '>'. I've just implemented this logic (at least I think so). The diff is a bit more complicated then it needs to be, but if you don't like this implementation, I'm going to add some backtracking code which should do somewhat better.