feat: html rendering

This commit is contained in:
2026-03-12 14:52:29 +01:00
parent 60f763df19
commit eb8f4574bf
10 changed files with 191 additions and 93 deletions

21
src/sh/preview.sh Normal file
View File

@@ -0,0 +1,21 @@
# Preview functions
# Preview email
# If a thread identifier is given, then the last message in the thread is
# shown. If the HTML flag is set, then the HTML message is parsed using pandoc.
# This functions reverts to the HTML method if no HTML flag is set yet no
# text/plain part is found.
#
# @argument $1: "id" or "thread"
# @argument $2: message id or thread id
# @argument #3: if set, then the HTML messages will be taken
preview_message() {
[ "$1" = "id" ] && messageid="$2" || messageid="$(nm_last_message_in_thread "$2")"
parts="$(nm_message_parts "$messageid")"
html="${3:-}"
nr="$(nm_message_part_nr "$messageid" "$html")"
[ ! "$nr" ] && [ ! "$html" ] && html="html" && nr="$(nm_message_part_nr "$messageid" "html")"
[ "$html" ] && parser="$PANDOC" || parser="cat"
nm_message_header "$messageid" | $CATEMAIL
nm_message_get_part "$messageid" "$nr" | $parser | $CATMD
}