Lua for Elinks

Lua is a scripting language that can be used to extend the functionality of Elinks console browser. Lua can mangle webpages to render them more suitable to Elinks. Lua can also tweak Elinks’ settings in some contexts and launch external programs.

These days, Elinks console browser is commonly pre-compiled for Linux distros with lua support, so the only thing for the user to do is to begin writing extension scripts in lua. But some, such as myself, may be very weak in scripting, and need tutorials and samples.

The best sample is the official hooks.lua file for Elinks. Grab this file, save it to the .elinks directory and enjoy a different console browsing experience on Reddit, Linux Today and Dictionary.com, along with other websites mentioned in the file.

Study the file to devise hacks for the sites that you actually visit with Elinks. I would show what I came up with, but amazingly this blogging environment makes it too difficult to share pure code. <pre> and <code> tags get mangled.

The hooks.lua file testifies that it’s possible to expand Elinks’ keybinds, modify settings and call external programs by means of lua. It even makes YT work in Elinks via youtube-dl! These are all interesting areas to explore.

3 Replies to “Lua for Elinks”

  1. You can share pure code if you toggle the editor to the raw HTML view, enter the there and HTML escape your code before you insert it between the elements.

  2. How to “HTML escape” the code? I know how to slap tags around code, but I don’t know how to “HTML escape” it.

    EDIT: After some googling, I guess I got it. You suggest I paste the code through this http://www.freeformatter.com/html-escape.html
    Frankly, I think this blog should comprehend code and pre tags in a standard way. Or it should be possible to embed/attach text files here. Maybe some other time I will try HTML escape too.

  3. I found a way how Vivaldi can HTML escape all by itself. I used to type pure HTML locally and then paste it in the source code view into Vivaldi.net. Vivaldi.net does not like this. So here’s a workaround I found.

    In Vivaldi.net, we have to

    – Take the WYSIWYG view in blog composer
    – Select Code in the Format menu or Pre in the Paragraph menu
    – Paste the codebit in WYSIWYG

    Now, when you see the source code, you will see that the code has been properly “HTML escaped” so that Vivaldi.net can publish what the user intended. Not too elegant, but I guess I can live with this.

Leave a Reply

Your email address will not be published. Required fields are marked *