jeremy-compostella / org-msg

OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
GNU General Public License v3.0
281 stars 61 forks source link

Proper way to inject css #174

Open pseudomyne opened 1 year ago

pseudomyne commented 1 year ago

Hi, I fail to inject some css in my emails.

I have (setq org-msg-enforce-css org-msg-default-style) Preview is formated correctly (C-c C-e), but once sent to gmail, it won’t render as such.

I have tried to play with some org export options like org-html-head-include-default-style t / nil and org-html-html5-fancy t / nil with no result.

I also tried to inject external css with#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="/home/me/style.css"/>, Again it's ok within the preview, but won’t be sent through mail. What options do I miss here ?

@mclearc : would you mind sharing your (whole) config options ?

WillForan commented 1 week ago

As far as I know, email clients can't/won't use <link> for styling, and I think even file-local <style> is ignored by some if not most. org-msg uses the style property list defined in org-msg-default-style to inline styles in every html element that needs them (like <pre style="background:black">). (org-msg-default-style use your current emacs theme to set colors!)

You can modify org-msg-default-style but that's an uphill battle with an additional maintenance burden. Alternatively, org-msg-enforce-css can be set to a css file (that will be read in by org-msg, converted to the same structure as org-mgs-default-style, and then inlined for each matching html element to be stylized). I'm working on a function that can create a suitable css from the defaults that you could then modify

Here's an example with the zerodark theme active with small modification to add a border to pre blocks: org-msg.css.txt