~chambln/public-inbox

Integrate gmir v1 PROPOSED

codesoap: 1
 Integrate gmir

 1 files changed, 13 insertions(+), 18 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~chambln/public-inbox/patches/39621/mbox | git am -3
Learn more about email & git

[PATCH] Integrate gmir Export this patch

Hi Greg,
I can see that there has already been some discussion about how to
implement syntax highlighting for gmi files. You had suggested to create
a custom pager, that is based on less.

I have recently written a pager specifically for text/gemini and thought
you might find it interesting. It doesn't just do syntax highlighting,
but also word wrapping and, perhaps more interestingly, link selection.

I think that the link selection makes browsing a lot smoother. I have
attached a simple demo-patch (that assumes PAGER=gmir) below.

You can find the source at https://github.com/codesoap/gmir and a little
blog post about it at gemini://rulmer.xyz/gmir.gmi .

Greetings,
Richard Ulmer
---
 gmi | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/gmi b/gmi
index 2262609..cddcb67 100755
--- a/gmi
+++ b/gmi
@@ -126,28 +126,23 @@ success() (
            case ${format-fixed} in
                [Ff][Ll][Oo][Ww][Ee][Dd]) LESS=S$LESS ;;
            esac
            printf %s "$response" |
            uri="$(printf %s "$response" |
                base64 -d |
                sed '1d;s/\r$//' |
                iconv -f "${charset-UTF-8}" |
                pager
            {
                printf '[%s] \033[4m\033[34m%s\033[m %s\n' \
                       B "$back" Back \
                       U ../ Up \
                       R "$path" Reload
                printf %s "$response" |
                    base64 -d |
                    sed 1d |
                    iconv -f "${charset-UTF-8}" |
                    awk '/^```/ { pre = (pre + 1) % 2; next }
                         ! pre && sub("^=>", "") {
                             $1 = "[" ++i "] \033[4m\033[34m" $1 "\033[m"
                             print
                         }'
            } | fzf --ansi | while IFS=' 	' read -r _ uri _; do
                    main "$uri"
                pager)"
            if [ -z "$uri" ]; then
                {
                    printf '[%s] \033[4m\033[34m%s\033[m %s\n' \
                           B "$back" Back \
                           U ../ Up \
                           R "$path" Reload
                } | fzf --ansi | while IFS='    ' read -r _ uri _; do
                        main "$uri"
                done
            else
                main "$uri"
            fi
            ;;
        *)
            printf %s "$response" | base64 -d | sed 1d > "${path##*/}"
-- 
2.37.3