Search code examples
matlabgmailmarkdown

Matlab publish displays code incorrectly as an email attachment?


Normally, when I look at the HTML output of the matlab publish command it highlights code, and visually separates code from formatted text, and output with a separating box, with light gray background like this:

enter image description here

But, when I sent the html file to a friend as an attachment in gmail, and viewed it in gmail in chrome, on a Windows7 machine, the separating box and gray background are missing, and readability is worse.

I assume this is probably a gmail "feature" to make sure the HTML isn't doing something evil? Or, did I do something wrong in my publish?

enter image description here

The smallest reproducible example of this is:

%% Load CSV files:
%
% Matlab has an CSV file import wizard to parse CSV files.
%
users = importUsers('users.csv');
viewings = importViewings('viewings.csv');

Solution

  • I was able to reproduce this on my system with both chromium and firefox. The reason for this is that the HTML preview in gmail strips the css (and probably any js) linked to or stored in the HTML. This post might have some relevant information.

    The solution is quite simple - just save the file to your device and open it afterwards (the formatting is only removed from the preview, not from the actual file).