[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lynx-dev] Transferring page text from lynx to vim

From: Bela Lubkin
Subject: Re: [Lynx-dev] Transferring page text from lynx to vim
Date: Sun, 2 Oct 2011 22:33:35 -0700

Thomas Dickey wrote:

> On Sun, 2 Oct 2011, Graham Lawrence wrote:
> > Does lynx happen to put the address of the current page in some global
> > variable?   So then I could create a key mapping in vim that would cause
> > lynx to dump the page to a constant filename, and insert that file's text
> > where I want it in the vim buffer.
> But dumping is a special case of display - it bypasses most of GridText.c
> However - to your point - when you're telling lynx to dump a file, that
> goes to the standard output.  Redirecting that with a script should be
> simple.  (That doesn't require knowing anything about the variables that
> lynx uses).

An `html2ascii` script I once wrote has at its core the following

   lynx -dump -justify=off -with_backspaces -display_charset=us-ascii \
        -width=$WIDTH -nolist -force_html address@hidden/dev/stdin}

-- some parts of which are specific to the setting I had it in.

Breaking it down:

   -dump              Parse HTML, output formatted text
   -justify=off       Because I hate it ;-}
   -with_backspaces   Use x^Hx, x^H_ formatting for bold, underline
                      (probably not desirable for vim insertion; looks
                      good in `less`)
   -display_charset=us-ascii   Force 7-bit output -- probably not wanted
   -width=$WIDTH      Column width of output ($WIDTH prev. calculated)
   -nolist            Don't append table of link URLs
   -force_html        Override in case we're using /dev/stdin
   address@hidden/dev/stdin}    POSIX shell syntax for "This script's arguments,
                      or if none, /dev/stdin (standard input)"

With no args, it's a filter; with args, it dumps each arg.  Args can be
local files (foo.html; bar.txt -- which will still be read as HTML), or
URLs (  Output is concatenated with no

Suppose you've saved something based on this as a script on your path,
named lynx2ascii.  Then inside vim you could do:


to dump a section of HTML to ASCII with no intermediate output file.

I don't quite understand the concept of "Lynx's current page" if you are
inserting into a vim buffer.  That implies you are *in* vim, not Lynx.
If you invoke Lynx on vim's behalf (like above), you have to pass it a
URL or local filename or stdin.

Or are you proposing to have a key in *Lynx* which means "dump the
current page into a file, then run vim on that file"?  For that, look at
the PRINTER/DOWNLOADER section of lynx.cfg.  The `most` examples are
probably a good starting point.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]