Commit Graph

19 Commits

Author SHA1 Message Date
q3cpma d925ac8f72 filters: make it explicit that encoding is UTF-8
Document filter input charset
Add w3m filter example to default config
Adapt html and html-unsafe filters

Fixes: https://todo.sr.ht/~rjarry/aerc/65
Signed-off-by: q3cpma <q3cpma@posteo.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-03 22:36:51 +02:00
Koni Marti ab941ebc6a filters: posix compliant rewrite of calendar filter
Rewrite of the awk calendar filter to make it posix compliant. Tested
with awk --posix (awk -V = GNU Awk 5.1.1). Also added some improvements
to readability and formatting.

This complements commit 3ef4a3ca05 ("filters: try and make awk scripts
posix compliant").

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-24 23:06:36 +02:00
Robin Jarry 3ef4a3ca05 filters: try and make awk scripts posix compliant
\x escape sequences are GNU specific. Use the octal escape code instead.

filters/calendar is beyond help. It would need a complete rewrite to
make it work with POSIX awk.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-18 13:58:21 +02:00
Robin Jarry 142647d7c9 filters/colorize: use /usr/bin/awk shebang
/bin is reserved for essential commands that may be used when in single
user mode.

Link: https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html#binEssentialUserCommandBinaries
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-07-11 21:15:56 +02:00
Tom Schwindl fc4301113e filters: Add missing shebangs
The hldiff and plaintext filter scripts are missing their shebangs.
Add those to be correct and consistent.
Additionally, remove the vim comment, it's unnecessary.

Signed-off-by: Tom Schwindl <schwindl@posteo.de>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-11 15:53:23 +02:00
Koni Marti 527f602f36 filters: awk filter to parse text/calendar
Implement a filter to read text/calendar (ics) data with awk.
Parses multiple events and shows the date recurrence if
available. Awk alternative to the python filter.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-31 14:32:00 +02:00
Jens Grassel 1ecee8efa5 Add html "unsafe" filter to work also without dante
If socksify (from dante) is not installed then the filter uses w3m
without it to render an html message part.

Signed-off-by: Jens Grassel <jens@wegtam.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-17 12:17:43 +02:00
Jens Grassel 037676f7cc show-ics-details.py: fix error with python < 3.9
Change the pattern matching into a if/elif construct because pattern
matching is not supported on python < 3.9.

Signed-off-by: Jens Grassel <jens@wegtam.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-24 15:30:42 +01:00
Jens Grassel 374d3a0d01 Add filter script for ics files.
This is a python script for python 3 using the vobject library to show
details about an ics file (text/calendar attachment).

Signed-off-by: Jens Grassel <jens@wegtam.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2022-03-23 20:56:22 +01:00
Robin Jarry 807870ea35 colorize: handle mailto prefixes in urls
mailto:email@domain.tld is the only exception that does not use the
<scheme>:// prefix.

Requested-by: Moritz Poldrack <moritz@poldrack.dev>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2022-03-18 23:41:56 +01:00
Robin Jarry d2c239292e filters: fix colorize urls in signatures
When a signature contains a line that starts with an url, the url is not
highlighted properly:

  --
  Foobar
  [38;2;255;255;175mmhttps://foobar.org

The trailing m of the signature color start \x1b[38;2;175;135;255m is
considered as part of the URL scheme (i.e. mhttps:// instead of
https://). Colorize the URLs first before wrapping with the signature
color.

Fixes: df8c129235 ("filters: port colorize to awk")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-03-03 21:38:02 +01:00
Robin Jarry df8c129235 filters: port colorize to awk
Python is not available on all systems. Port the colorize filter to awk
as it is a more widespread POSIX utility.

Users are free to copy the filter into their home dir and tweak the
colors to their needs. The highlighted items are:

  =============== ======= ======= ========= =================
  Item            Red     Green   Blue      Color
  =============== ======= ======= ========= =================
  quoted text 1   95      175     255       Blue
  quoted text 2   255     135     0         Orange
  quoted text 3   175     135     255       Purple
  quoted text 4   255     95      215       Pink
  quoted text *   128     128     128       Grey
  diff meta       255     255     255       White bold
  diff chunk      205     0       205       Cyan
  diff added      0       205     0         Red
  diff removed    205     0       0         Green
  signature       175     135     255       Purple
  header          175     135     255       Purple
  url             255     255     175       Yellow
  =============== ======= ======= ========= =================

This assumes a terminal emulator with true color support and with
a dark/black background.

Link: https://github.com/termstandard/colors
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-21 19:16:00 +01:00
Robin Jarry 9dc2803220 filters: restore plaintext awk script
This script is referenced by some users configuration. Restore it to
avoid breaking existing setups.

Fixes: bca93cd915 ("filters: add a more complete plaintext filter")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-20 23:46:29 +01:00
Robin Jarry c63ca9bd9c filters: rename plaintext to colorize
This filter script is not compatible with the previous one. Rename it to
avoid issues with existing configs.

Fixes: bca93cd915 ("filters: add a more complete plaintext filter")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-20 23:46:29 +01:00
Robin Jarry bca93cd915 filters: add a more complete plaintext filter
Colorize most plain text messages.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-19 22:14:27 +01:00
Robin Jarry 7c3ce816c8 config: set a default filter for text/plain
Avoid the following issue when running aerc with the default
configuration:

  No filter configured for this mimetype ('text/plain')

Use a very basic sed command to replace the default plaintext filter.

Fixes: bb0f180140 ("config: do not hardcode sharedir")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-19 22:12:16 +01:00
Daniel Xu ea4fe71360 Strip carriage returns (^M) when filtering emails
Presumably some email servers will transform newlines into carriage
return new lines to better support windows users. I can't prove this but
that's the best explanation I have for my hosted email provider
(fastmail).

Without this patch, I was seeing annoying `^M`s at the end of every
filtered line.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
2019-08-20 16:05:20 +09:00
EdOverflow 5ea5f914bf Escape plus symbol in hldiff filter.
I was getting errors when using the hldiff filter with aerc
because the plus symbol on line 28 wasn't escaped. This commit
escapes the plus symbol in the regex on line 28.
2019-07-13 12:28:49 -04:00
Drew DeVault 177651bdda Move contrib -> filters 2019-06-27 09:32:46 -04:00