Chapter 14. Scripting ELinks with Lua

Table of Contents

Introduction
What is it
Where to get it
What it runs on
Installing
Installing Lua
Installing ELinks
Running ELinks with Lua
Using ELinks with Lua
ELinks Lua additions
Config file
Hooks
Functions
Variables
User protocol
Example recipes
Go to URL on steroids
Expanding ~ (tilde)
Filtering crap
Reading gzipped files
Printing
Deferring to Netscape
Alternative bookmark system
More ideas

This file documents the Lua scripting interface of the ELinks web browser.

Introduction

What is it

Lua scripting capabilities permit users to customize the ELinks behaviour to unusual degree - they allow automatic rewriting of HTML code of the received documents, rewriting of the URLs entered by user etc. You can even write your own bookmarks system with Lua. See also contrib/lua/ for some examples of the possibilities of ELinks Lua support.

Please do not confuse Lua scripting with JavaScript, EcmaScript, VBScript and similar. Those are embedded in page, allowing per-document scripting related to its presentation and providing some degree of interactivity etc. On the contrary, the current Lua support permits scripts to be embedded to the browser directly, changing the behaviour of the browser, not the document.

The original Lua support (in the form of Links-Lua fork of original Links) was written by Peter Wang and Cliff Cunnington. There are some rough edges remaining, but is suitable for everyday use (I have been using it every day for a year).

Where to get it

The Lua scripting support comes with the stock ELinks distribution, no additional patches and tweaks should be needed.

The web site of the original Links-Lua is at http://links.sourceforge.net/links-lua/. Some older patches against regular Links are available at http://www.sourceforge.net/projects/links/, but they are not being maintained.

Lua can be found at http://www.lua.org/.

What it runs on

The Lua support has only been tested under Linux, although it should work under other platforms that ELinks and Lua support (perhaps with some changes to source code?).

Also, note that many of the scripts given here assume a Unix system. Your mileage will definitely vary on other platforms.