aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/aerc.conf11
-rw-r--r--config/config.go5
-rw-r--r--config/converters.go34
3 files changed, 50 insertions, 0 deletions
diff --git a/config/aerc.conf b/config/aerc.conf
index ecae5b90..05ebbf41 100644
--- a/config/aerc.conf
+++ b/config/aerc.conf
@@ -359,6 +359,17 @@
#
#no-attachment-warning=
+[multipart-converters]
+#
+# Converters allow to generate multipart/alternative messages by converting the
+# main text/plain part into any other MIME type. Only exact MIME types are
+# accepted. The commands are invoked with sh -c and are expected to output
+# valid UTF-8 text.
+#
+# Example (obviously, this requires that you write your main text/plain body
+# using the markdown syntax):
+#text/html=pandoc -f markdown -t html --standalone
+
[filters]
#
# Filters allow you to pipe an email body through a shell command to render
diff --git a/config/config.go b/config/config.go
index c4794cc1..b5cc0d60 100644
--- a/config/config.go
+++ b/config/config.go
@@ -18,6 +18,7 @@ type AercConfig struct {
Bindings BindingConfig
ContextualBinds []BindingConfigContext
Compose ComposeConfig
+ Converters map[string]string
Accounts []AccountConfig `ini:"-"`
Filters []FilterConfig `ini:"-"`
Viewer ViewerConfig `ini:"-"`
@@ -140,6 +141,7 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
Viewer: defaultViewerConfig(),
Statusline: defaultStatuslineConfig(),
Compose: defaultComposeConfig(),
+ Converters: make(map[string]string),
Templates: defaultTemplatesConfig(),
Openers: make(map[string][]string),
}
@@ -153,6 +155,9 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
if err := config.parseCompose(file); err != nil {
return nil, err
}
+ if err := config.parseConverters(file); err != nil {
+ return nil, err
+ }
if err := config.parseViewer(file); err != nil {
return nil, err
}
diff --git a/config/converters.go b/config/converters.go
new file mode 100644
index 00000000..8c6b88df
--- /dev/null
+++ b/config/converters.go
@@ -0,0 +1,34 @@
+package config
+
+import (
+ "fmt"
+ "strings"
+
+ "git.sr.ht/~rjarry/aerc/log"
+ "github.com/go-ini/ini"
+)
+
+func (config *AercConfig) parseConverters(file *ini.File) error {
+ converters, err := file.GetSection("multipart-converters")
+ if err != nil {
+ goto out
+ }
+
+ for mimeType, command := range converters.KeysHash() {
+ mimeType = strings.ToLower(mimeType)
+ if mimeType == "text/plain" {
+ return fmt.Errorf(
+ "multipart-converters: text/plain is reserved")
+ }
+ if !strings.HasPrefix(mimeType, "text/") {
+ return fmt.Errorf(
+ "multipart-converters: %q: only text/* MIME types are supported",
+ mimeType)
+ }
+ config.Converters[mimeType] = command
+ }
+
+out:
+ log.Debugf("aerc.conf: [multipart-converters] %#v", config.Converters)
+ return nil
+}