aboutsummaryrefslogtreecommitdiffstats
path: root/filters
Commit message (Collapse)AuthorAgeFilesLines
* colorize: add 'terminal' theme which respects termcolorsTim Culverhouse2022-12-211-0/+16
| | | | | | | | | | | | Add a "terminal" theme to colorize script. The "terminal" theme respects the users' configured terminal color scheme. Also links are blue underlined. Usage: colorize -v theme=terminal Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* wrap: handle letters as list itemsRobin Jarry2022-12-141-1/+1
| | | | | | | | | | | In addition of digits, handle lower case letters as list items: a) foo b) baz c) bar Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* filters: add wrap utility written in goRobin Jarry2022-12-052-0/+479
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I had started writing this as an awk script but quickly got stuck with obscure code which did not even work properly. I jumped the gun and re did it in go. Bonus, we will not have MacOS's 1987 BSD awk issues. On the other hand, instead of a 20.0K awk script, we now have a 2.2M static go binary. If this makes people scream, I challenge them to do that with BSD awk :) Basically, this takes text from stdin or from a file and wraps long lines on word boundaries. It takes care of not breaking up email quotes nor list items (numbered as well). Also, it is conservative by default and only wraps long lines and lines that end with a space (indicating a format=flowed message). If the AERC_SUBJECT environment variable is defined and contains the word PATCH, the text is not modified at all (i.e. wrap behaves as cat(1)). There are a few command line options to control behavior: Usage of ./wrap: -f string read from file instead of stdin -l int minimum percentage of letters in a line to be considered a paragaph (default 50) -r reflow all paragraphs even if no trailing space -w int preferred wrap margin (default 80) Update docs, makefile and default config file with examples. Add a torture test to ensure it works as expected. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* colorize: add solarized themeJens Grassel2022-11-301-15/+42
| | | | | | | | | | | | | | | This modifies the colorize script to accept a command line parameter to change the colour theme. Currently only a solarized version is added. Due to the nature of awk the theme has to be defined via the `-v` flag. Due to the `switch` statement only being available in GNU awk we use a `if else` statement to ensure that the default colours are used if either the `THEME` variable is not set at all or set to `default`. Solarized colour scheme: https://ethanschoonover.com/solarized/ Signed-off-by: Jens Grassel <jens@wegtam.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* colorize: make it compatible with BSD awkRobin Jarry2022-10-231-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the following error seen on MacOS: /usr/bin/awk: syntax error at source line 22 source file header_pattern = >>> @ <<< /^[A-Z][[:alnum:]-]+:/ The @ character in front of regular expressions to pre-compile them seems not in the POSIX specification. Replace them with regular strings and call match() instead of the ~ operator. Also, adjust the url_pattern expression for BSD awk which explicitly states: The awk utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification, except awk does not support {n,m} pattern matching. Use [[:lower:]]+ instead of [a-z]{2,6}. Tested with: GNU Awk 5.1.1 awk version 20121220 (FreeBSD) Link: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html Fixes: https://todo.sr.ht/~rjarry/aerc/96 Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* filters/colorize: various fixesRobin Jarry2022-10-201-27/+19
| | | | | | | | | | | | | | | | Diff chunks can occur in the middle of email conversations followed by regular and/or quoted text. Handle that properly. Change diff meta lines inside quotes to bold. Update the meta lines with more combination for renamed, copied and deleted files. Fix the diff_chunk invalid color code, only colorize the chunk characters, not the whole line. Remove redundant variable resets to 0. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-on-irc-by: Tim Culverhouse <tim@timculverhouse.com>
* filters: fix calendar filter parsingKoni Marti2022-08-221-5/+16
| | | | | | | | | | Fix parsing of colons. Since the field separator is also the colon, it could mess up the parsed fields, i.e. a subject line like "WG: dinner" could end up as "WG" instead of keeping the entire string. Fixes: ab941eb ("filters: posix compliant rewrite of calendar filter") Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* filters: make it explicit that encoding is UTF-8q3cpma2022-08-032-0/+2
| | | | | | | | | | 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>
* filters: posix compliant rewrite of calendar filterKoni Marti2022-07-241-178/+109
| | | | | | | | | | | | 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 3ef4a3ca051a ("filters: try and make awk scripts posix compliant"). Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* filters: try and make awk scripts posix compliantRobin Jarry2022-07-182-16/+16
| | | | | | | | | | \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>
* filters/colorize: use /usr/bin/awk shebangRobin Jarry2022-07-111-1/+1
| | | | | | | | /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>
* filters: Add missing shebangsTom Schwindl2022-07-112-2/+4
| | | | | | | | | 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>
* filters: awk filter to parse text/calendarKoni Marti2022-05-311-0/+328
| | | | | | | | | 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>
* Add html "unsafe" filter to work also without danteJens Grassel2022-04-171-0/+16
| | | | | | | | 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>
* show-ics-details.py: fix error with python < 3.9Jens Grassel2022-03-241-16/+16
| | | | | | | | 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>
* Add filter script for ics files.Jens Grassel2022-03-231-0/+89
| | | | | | | | 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>
* colorize: handle mailto prefixes in urlsRobin Jarry2022-03-181-1/+1
| | | | | | | | | 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>
* filters: fix colorize urls in signaturesRobin Jarry2022-03-031-1/+1
| | | | | | | | | | | | | | | | | 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: df8c129235d9 ("filters: port colorize to awk") Signed-off-by: Robin Jarry <robin@jarry.cc>
* filters: port colorize to awkRobin Jarry2022-02-211-168/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* filters: restore plaintext awk scriptRobin Jarry2022-02-201-0/+16
| | | | | | | | This script is referenced by some users configuration. Restore it to avoid breaking existing setups. Fixes: bca93cd91536 ("filters: add a more complete plaintext filter") Signed-off-by: Robin Jarry <robin@jarry.cc>
* filters: rename plaintext to colorizeRobin Jarry2022-02-201-0/+0
| | | | | | | | This filter script is not compatible with the previous one. Rename it to avoid issues with existing configs. Fixes: bca93cd91536 ("filters: add a more complete plaintext filter") Signed-off-by: Robin Jarry <robin@jarry.cc>
* filters: add a more complete plaintext filterRobin Jarry2022-02-191-0/+171
| | | | | | Colorize most plain text messages. Signed-off-by: Robin Jarry <robin@jarry.cc>
* config: set a default filter for text/plainRobin Jarry2022-02-191-16/+0
| | | | | | | | | | | | 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: bb0f1801402e ("config: do not hardcode sharedir") Signed-off-by: Robin Jarry <robin@jarry.cc>
* Strip carriage returns (^M) when filtering emailsDaniel Xu2019-08-202-0/+9
| | | | | | | | | | | | 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>
* Escape plus symbol in hldiff filter.EdOverflow2019-07-131-1/+1
| | | | | | 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.
* Move contrib -> filtersDrew DeVault2019-06-273-0/+62