[Tutor] Creating a list from other lists

eryksun eryksun at gmail.com
Tue Oct 23 12:31:18 CEST 2012


On Tue, Oct 23, 2012 at 4:51 AM, Walter Prins <wprins at gmail.com> wrote:
>
> Looking at the email source it clearly shows as being mimetype
> "multipart" with both a plaintext and HTML part.  I don't think you
> can much criticise GMail for interpreting and attempting to render an
> HTML email as HTML.  The biggest culprit here IMHO was the sending
> mail client that generated a broken text mode version of the email's
> intended formatting by dropping the indentation (and if the HTML is
> broken, generated broken HTML to boot as well.)

The message looks to have been sent with Gmail's webmail client. The
problem I think starts with Webkit. When the user presses <tab> in a
rich text box, instead of tabbing between fields on the page, it
inserts a <span class="Apple-tab-span" style"white-space:pre">
element.

I tested how Gmail handles this by creating a simple HTML file
containing the following:

<div>for x, y , z in zip(a, b, c):</div><div><span
class="Apple-tab-span" style="white-space:pre">	</span>L.extend([x, y,
z])</div><div><span class="Apple-tab-span"
style="white-space:pre">	</span>print L</div>

I rendered this in Firefox and copied it into a new rich text email.
Gmail stripped out the tab characters before rendering the plain text
section as follows:

for x, y , z in zip(a, b, c):
L.extend([x, y, z])
print L

They certainly could be smarter when it comes to spans with
"whitespace:pre" styling, but it's better if users would just think to
use plain text when posting code.

That said, plain text with Gmail has its own pitfalls. To render it
correctly with a monospace font in the web client you need to use
something like Stylish to hack Gmail's CSS. But, more importantly, you
have to be wise to Google's line wrapping at 69 characters (no RFC
requires this). It doesn't give you a live preview. Instead you have
to manually wrap code at 69 columns in an IDE and paste it into the
text box. Otherwise your code will probably get mangled.


More information about the Tutor mailing list