Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math/Latex Support #712

Open
drdrjacobs opened this issue Jul 27, 2021 · 6 comments
Open

Math/Latex Support #712

drdrjacobs opened this issue Jul 27, 2021 · 6 comments

Comments

@drdrjacobs
Copy link

Would it be possible to add support for including latex formulas in emails?

There is currently no great option for including latex in emails, so this would be hugely helpful for those that work in math/science fields.

It seems like this maybe was a planned feature at some point:

#689 (comment)

but it hasn't been mentioned since.

@gauteh
Copy link
Member

gauteh commented Jul 27, 2021 via email

@drdrjacobs
Copy link
Author

drdrjacobs commented Jul 27, 2021

and not renderable on receiver unless also using astroid

I see. So the dream would be to get math working in a way that most receivers can see it, and then include some kind of fallback if not as discussed here:

https://superuser.com/a/892901

It's crazy that getting that working is so messy.

I guess an alternative that is probably pretty accessible would be to automatically attach a rendered pdf to the email if it contains math. Is this something that could be done as a plugin?

@gauteh
Copy link
Member

gauteh commented Jul 28, 2021 via email

@mreppen
Copy link

mreppen commented Sep 17, 2021

But then we need a reliable plain-text fallback.

I might be in a bubble, but in my setting, the TeX code itself is a good fallback, as that is what my contacts write anyway.

@gauteh
Copy link
Member

gauteh commented Sep 18, 2021 via email

@jorsn
Copy link
Member

jorsn commented Oct 2, 2022

You could just use the markdown feature and pandoc. From my config:

 "markdown_on": true,
 "markdown_processor": "/path/to/pandoc --mathml --self-contained -M pagetitle=Email --template=/path/to/template/template.html --resource-path=.:/home/johannes/Maildir/styles:",
My template.html, derived from the one supplied with pandoc: (click to expand)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="pandoc" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
  <style>
      code{white-space: pre-wrap;}
      span.smallcaps{font-variant: small-caps;}
      span.underline{text-decoration: underline;}
      div.column{display: inline-block; vertical-align: top; width: 50%;}
$if(quotes)$
      q { quotes: "“" "”" "‘" "’"; }
$endif$
  </style>
$if(highlighting-css)$
  <style>
$highlighting-css$
  </style>
$endif$
$for(css)$
  <link rel="stylesheet" href="$css$" />
$endfor$
$if(math)$
  $math$
$endif$
$for(header-includes)$
  $header-includes$
$endfor$
</head>
<body>
$for(include-before)$
$include-before$
$endfor$
$if(title)$
<header id="title-block-header">
<h1 class="title">$title$</h1>
$if(subtitle)$
<p class="subtitle">$subtitle$</p>
$endif$
$for(author)$
<p class="author">$author$</p>
$endfor$
$if(date)$
<p class="date">$date$</p>
$endif$
</header>
$endif$
$if(toc)$
<nav id="$idprefix$TOC" role="doc-toc">
$table-of-contents$
</nav>
$endif$
$body$
$for(include-after)$
$include-after$
$endfor$
</body>
</html>

Then, you can easily compose html mails, even styled ones by adding a YAML metadata block like

---
title: Hello World
css: fancy-style.css
---

to the top of your email, where fancy-style.css is in the directory /home/johannes/Maildir/styles.

If you want images instead of mathml for broader support, you can use GladTeX as described in the pandoc manual: First run pandoc to produce htex file, then run gladtex to produce html file, finally run pandoc with option --embed-resources to produce html with inlined images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants