[elinks-users] Hook: URL dependent keybinding for link access?
Miciah Dashiel Butler Masters
miciah at myrealbox.com
Thu Jul 21 14:00:52 PDT 2005
On Thu, Jul 21, 2005 at 11:39:35AM +0200, Robert Michel wrote:
> Salve Doug!
> On Thu, 21 Jul 2005, Doug Kearns wrote:
> > On Wed, Jul 20, 2005 at 11:51:02PM +0200, Robert Michel wrote:
> > > (Would be nice to use vim Syntaxhighligtin and
> > > mutt parsing to make plain text URL or plain Wiki text
> > > [elinks] -> en.wikipedia.org/wiki/elinks
> > > accessable) ;)
URIs are made into links when you view a plain-text file.
> > You can do this with the (lua|guile|perl|python|ruby) scripting
> > pre_format_html_hook. Alternatively have a look at
> > http://www.privoxy.org/
It is tricky to automatically linkify URIs without corrupting some
pages--you can't just convert any string that resembles a URI into
a link, because a URI might be part of the definition of a link,
a reference to a style-sheet, or part of some ECMAScript, for example.
You don't want to convert <a href='http://foo.com/'>foo</a> into
<a href='<a href='http://foo.com/'>http://foo.com/</a>'>foo</a>.
Someday, ELinks will move to the DOM renderer, and then we can allow
XSLT scripts, which would make it an easy task.
> Hey cool, pre_format_html_hook was what I was looking for.
> Also --StayOnHost --StayOnUrl will be possible to do with
> it and much, much more to play with :)
I'm not sure how feasible that would be. Do you plan to strip references
to other hosts out of the document source? That would be tricky to do
without potentially corrupting some documents.
> Is there a way to have a standard pre_format_html_hook
> for all pages?
That is how pre_format_html_hook works. In the hooks.lua that comes
with ELinks, most of the hooks specifically check the current URI
to determine whether they should run.
If a hook doesn't perform that check, that hook runs 'for all pages'.
> > > 2.) Is it already possible to use a parser to
> > > open Links? E.g. webpage contains a Link with the Name
> > > "next" hotkey "n" for direct access for this Link?
> > I might be misunderstanding you but elinks provides access to link
> > elements in a list at the top of the page. Try http://www.w3.org for an
> > example.
> The idea is that some pages have keywords for their pagenavigation:
> "next", "back" and I would like to have keybindings like
> "n", "b" to access this links without mouse.
> This hook should be configurable for different domains.
> I guess I should/can use the luna-console to to this.
Use the accesskey attribute for links: <a href='http://foo.com/'
accesskey='n'>foo</a> will give you a link that you can select
by pressing alt-n. If that does not work, check the value of the option
Document -> Browsing -> Access keys -> Access key priority.
> But within the luna-console (started with ",")
> return "goto-url", "http://www.debian.org"
> or even
> return nil
> Gives the error:
> Elinks: Lua: bad argument for eval
> What's wrong?
lua_console_hook itself or a callback for bind_key, xdialog,
or edit_bookmark_dialog can return "eval", "run", or "goto_url"
and another value to get the desired behaviour. ELinks will read
the returned string, see that it begins with "eval" or whatever,
and perform the appropriate task.
If you enter a string into the Lua console, the lua_console_hook
takes that string and returns "eval" and that string to ELinks.
ELinks will then tell Lua to evaluate that string. Lua has no idea
how to interpret a string like '"goto-url", "http://www.debian.org"'.
What you might do is change lua_console_hook to check whether
the given string begins with "goto-url" and, if so, just return
the entered string, without "eval" added, to ELinks so that ELinks
will interpret the "goto-url" rather than passing it on to Lua.
> > > 5.) Would be nice to have a function for bookmarked
> > > pages to leave out parts of the webpage (not needed
> > > text, menues, links...) - Does somebody knows a
> > > proxy to filter out unneeded content?
> > See answer to question 1.
> Thank you - have a good day,
> PS: Shame on my that I had ask the FAQ about copy/past,
> I had used it several times but forgot it again...
> sorry ;)
Miciah Masters <miciah at myrealbox.com> / <mdm0304 at mail.ecu.edu>
More information about the elinks-users