help.txt lynx-integration.txt                               

                           Lynx Integration

Lynx is a command line browser for linux. If it is installed it can be used 
together with Liquid by adding the code below to .liq.

The code defines a keybinding gw (read goto web). If gw is typed while the 
cursor is on a link, Lynx will be used to display the content of the page in 

If gw is typed while inside brackets with a number, like "[99]", Liquid will 
look for a matching link reference starting with 99:  and grap the link 
from there. This is how Lynx displays links.

Code to be added to .liq

(ns user
  (:require [liq.editor :as editor]
            [liq.buffer :as buffer]
            [ :as shell]))

(def regex-url
    (str "https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\."

(def regex-ref #"(?<=\[)\d+(?=\])")

(defn jump-link
  "If this function is called while the cursor is on a hyper link
  a new buffer with the target of the link will be displayed using
  Lynx (Which has to be installed).
  If the cursor is inside brackets with a number. The number will
  be looked up at the bottom of the buffer to get a link."
  (let [buf (editor/current-buffer)
        u (buffer/thing-at-point buf regex-url)
        n (buffer/thing-at-point buf regex-ref)
        w (buffer/word buf)]
    (cond u (editor/new-buffer ((shell/sh "lynx" u "--dump") :out) {:name w})
          n (let [text (buffer/text buf)
                  hit (second (re-find (re-pattern (str " +" n "\\. (.+)"))
              (when hit
                  ((shell/sh "lynx" hit "--dump") :out)
                  {:name hit}))))))

(swap! editor/state assoc-in
       [::editor/commands :jump-link] jump-link)

(swap! editor/state assoc-in
       [::editor/modes :fundamental-mode :normal "g" "w"] :jump-link)