diff --git a/bin/view-email-html b/bin/view-email-html index 33a8502..403ed74 100755 --- a/bin/view-email-html +++ b/bin/view-email-html @@ -29,27 +29,36 @@ else echo '' echo "" echo "
" echo '' echo "" # Extract and display headers (handles multi-line headers) @@ -108,13 +117,15 @@ else # Only split To, CC, Bcc addresses (not Date, Subject, From) if (tolower(header) ~ /^(to|cc|bcc)$/) { n = split_addresses(value, addrs) + printf "" header ": "
if (n > 1) {
- print " " header ": " header ": " value ""
- for (i=1; i<=n; i++) print "
"
+ for (i=1; i<=n; i++) printf "" addrs[i] ""
} else {
- print "
" header ": " value "
" } else { print "" header ": " value "
" } @@ -150,15 +161,40 @@ else else body_content=$(sed '1,/^$/d' "$emlfile") fi - # Process body: escape HTML, handle code blocks and inline code + # Process body: escape HTML, handle code blocks, inline code, and quoted text + # First pass: detect quote blocks (lines starting with > followed by more > lines) echo "$body_content" | awk ' - BEGIN { incode=0 } + BEGIN { incode=0; inquote=0; quotebuf=""; quotecount=0 } + function flush_quote() { + if (quotebuf != "") { + # Only make collapsible if we have 3+ quoted lines + n = split(quotebuf, lines, "\n") + if (n >= 3) { + print "" + print quotebuf + print "
"; incode=1 }
next
}
+ /^>/ {
+ if (incode) { gsub(/, "\\<"); gsub(/>/, "\\>"); print; next }
+ gsub(/, "\\<")
+ gsub(/>/, "\\>")
+ if (quotebuf != "") quotebuf = quotebuf "\n"
+ quotebuf = quotebuf $0
+ next
+ }
{
+ flush_quote()
gsub(/, "\\<")
gsub(/>/, "\\>")
if (!incode) {
@@ -172,7 +208,10 @@ else
}
print
}
- END { if (incode) print "" }
+ END {
+ flush_quote()
+ if (incode) print ""
+ }
'
echo ""