astroid icon indicating copy to clipboard operation
astroid copied to clipboard

Math/Latex Support

Open drdrjacobs opened this issue 3 years ago • 6 comments

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:

https://github.com/astroidmail/astroid/issues/689#issuecomment-651297393

but it hasn't been mentioned since.

drdrjacobs avatar Jul 27 '21 21:07 drdrjacobs

This was actually an early feature, back in v0.2. Think I removed it because seldom use, and not renderable on receiver unless also using astroid. Or convert math to PNG. You can actually solve it by tweaking the theme and adding mathjax. Might have to allow js.

tir. 27. jul. 2021, 23:32 skrev Daniel Jacobson @.***>:

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) https://github.com/astroidmail/astroid/issues/689#issuecomment-651297393

but it hasn't been mentioned since.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/astroidmail/astroid/issues/712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN367V5S3GSRRWEMMJ2V3TZ4QVHANCNFSM5BDCJ2LQ .

gauteh avatar Jul 27 '21 21:07 gauteh

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?

drdrjacobs avatar Jul 27 '21 22:07 drdrjacobs

ons. 28. jul. 2021, 00:42 skrev Daniel Jacobson @.***>:

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.

Yes, using cid images is probably the best. But then we need a reliable plain-text fallback.

gauteh avatar Jul 28 '21 05:07 gauteh

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.

mreppen avatar Sep 17 '21 19:09 mreppen

Yeah, fair enough. No point in overcomplicating it.

fre. 17. sep. 2021, 21:59 skrev mreppen @.***>:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/astroidmail/astroid/issues/712#issuecomment-922047206, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN367QIZMXWBWQMVEMPI3UCOM3DANCNFSM5BDCJ2LQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

gauteh avatar Sep 18 '21 05:09 gauteh

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.

jorsn avatar Oct 02 '22 17:10 jorsn