Re: HTML messages once again

[email protected] (John E. Davis) Wed, 2 Sep 2015 23:49:44 -0400
Newsgroups gmane.network.slrn.user
Message-ID <[email protected]>
Matěj Cepl <[email protected]> wrote:
> I don’t want to open the message in a HTML browser. The ideal
> would be something like mutt’s mechanism which allows me to run
> filter on the message to replace the body of the message with
> its output. If I have to use mailcap (as with mutt), then
> I would be willing to do that, but I would prefer something more
> simple.

The code below provides two functions that you can bind to
article-mode keys:

   lynx_view_article:
     View the current (html) article using lynx

   lynx_filter_article:
     Filter the current article with lynx

I believe the second one is the one you want.  Before using these,
please upgrade to the version pre1.0.3-6 that is in the git repository:

   git://git.jedsoft.org/git/slrn.git

Hopefully you will find this useful.
Thanks,
--John

require ("mime");
private define lynx_process_article (interactive)
{
   variable
     str = article_as_string (),
     i = is_substr (str, "\n\n"),
     head = substr (str, 1, i),
     body = substr (str, i+2, -1),
     tmpfile = sprintf ("/tmp/slrn-lynx-%X-%X.html", getpid(), _time()),
     fp = fopen (tmpfile, "w");

   if (fp == NULL)
     throw OpenError, "Could not open $tmpfile for writing"$;
   () = chmod (tmpfile, 0600);
   () = fwrite (body, fp);
   () = fclose (fp);

   try
     {
	if (interactive == 0)
	  {
	     fp = popen ("lynx -dump $tmpfile"$, "r");
	     body = strjoin (fgetslines (fp));
	     replace_cooked_article (head + "\n" + body);
	     return;
	  }

	set_display_state (0);
	() = system ("lynx $tmpfile"$);
     }
   finally
     {
	set_display_state (1);
	() = remove (tmpfile);
     }
}

define lynx_view_article ()
{
   lynx_process_article (1);
}

define lynx_filter_article ()
{
   lynx_process_article (0);
}

%definekey ("lynx_view_article", "\ev", "article");
%definekey ("lynx_filter_article", "\ev", "article");

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140