diff options
author | tv <tv@krebsco.de> | 2025-07-28 22:52:07 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2025-07-28 22:52:07 +0200 |
commit | ba1d3d9865d9f65ae70e5d9b28cb0b36f750f0c7 (patch) | |
tree | bebc7aa2928b134a0e8f73f98b484d7b7fdc2f7b | |
parent | 48b42494fc7414832d45f019c16b6b7a44fa6333 (diff) |
html render html parts with lynx
-rw-r--r-- | src/Much/TreeView.hs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Much/TreeView.hs b/src/Much/TreeView.hs index e963497..9b309bc 100644 --- a/src/Much/TreeView.hs +++ b/src/Much/TreeView.hs @@ -25,6 +25,8 @@ import Notmuch import Notmuch.Message import Notmuch.SearchResult import Much.TreeView.Types as Export +import System.Exit (ExitCode(ExitSuccess)) +import System.Process.ByteString.Lazy (readProcessWithExitCode) getMessage :: TreeView -> Maybe Message @@ -144,8 +146,26 @@ loadSubForest = \case . findFirsts messageMatch <$> notmuchShow (termFromMessage m) + TVMessagePart m mp@MessagePart{partContentType="text/html"} -> + notmuchShowPartRaw (termFromMessage m) (partID mp) >>= \case + Left e -> return $ Left $ show e + Right html -> + readProcessWithExitCode + "lynx" + [ "-dump" + , "-nomargins" + , "-stdin" + ] + html + >>= \case + (ExitSuccess, out, _err) -> + return $ Right $ + zipWith (\i s -> Node (TVMessageLine m mp i s) []) [0..] (lines . LBS8.unpack $ out) + + (exitCode, _out, err) -> + return $ Left $ show exitCode <> ": " <> LBS8.unpack err + TVMessagePart m mp -> - -- TODO parse --format=raw notmuchShowPart (termFromMessage m) (partID mp) >>= return . \case Left e -> Left $ show e Right mp' -> |