From fe91dea0af4208b78cbe367ef7bba52093fc83d3 Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 9 Nov 2021 10:11:53 +0000 Subject: [PATCH] try to detect html content in plain text FossilOrigin-Name: 9420ab4dc0b366555d31f0d5005bd5c2a854c4c82b69465631d50a122e6adedf --- chiroptera.d | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/chiroptera.d b/chiroptera.d index 181b500..c6c9899 100644 --- a/chiroptera.d +++ b/chiroptera.d @@ -617,6 +617,8 @@ void initConsole () { conRegVar!scrollKeepLines("scroll_keep_lines", "number of lines to keep on page up or page down."); conRegVar!unreadTimeoutInterval("t_unread_timeout", "timout to mark keyboard-selected message as unread (<1: don't mark)"); + conRegVar!preferHtmlContent("prefer_html_content", "prefer html content when both html and plain are present?"); + conRegVar!detectHtmlContent("detect_html_content", "detect html content in plain text?"); conRegFunc!clearBindings("binds_app_clear", "clear main application keybindings"); conRegFunc!setupDefaultBindings("binds_app_default", "*append* default application bindings"); @@ -1577,6 +1579,8 @@ class MarkAsUnreadEvent { __gshared int unreadTimeoutInterval = 600; __gshared int scrollKeepLines = 3; +__gshared bool preferHtmlContent = false; +__gshared bool detectHtmlContent = true; void postMarkAsUnreadEvent () { @@ -2212,18 +2216,25 @@ final class MainPaneWindow : SubWindow { foreach (auto row; stmtGet.st.bind(":uid", uid).range) { auto text = row.text!SQ3Text; auto html = row.html!SQ3Text; - if (text.xstrip.length == 0 && html.xstrip.length) { + bool isHtml = ((text.xstrip.length == 0 || preferHtmlContent) && html.xstrip.length != 0); + bool forceHtml = false; + if (detectHtmlContent && !isHtml && html.xstrip.length == 0 && text.xstrip.length != 0) { + auto tmp = text.xstrip; + if (tmp.startsWithCI("