sbs

A Simple Blogging System.
git clone https://git.sr.ht/~jbauer/sbs
Log | Files | Refs | README | LICENSE

commit 748af06ed50f265b21b126deb89b04d58a062363
parent f7ef8e5efb64e5c039a15ccd4c3ca99dab20ce16
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Thu, 18 Aug 2022 23:05:30 -0400

Fix support for Gemini links with optional label

Previously, if a Gemini link did not have a label, then sbs would skip
converting it to a Markdown-style link. For example:

=> /this/is/a/link.gmi

would not get converted whereas:

=> /this/is/a/link.gmi Link

would get converted. Since the label is optional according to the
gemtext specification, we need to support these situations.

Diffstat:
Msbs | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sbs b/sbs @@ -156,11 +156,14 @@ build() # in .gmi to .html (e.g. /blog/post1.gmi --> /blog/post1.html). # The second sed expression converts all gemini-style links to # markdown-style links. + # The third sed expression fixes gemini links that only had a + # URL so that the URL will be displayed as the link text in HTML if [ "$(echo "$file" | awk -F\. '{print $NF}' )" = "gmi" ]; then printf "Converting: %s to markdown...\n" "$file" fileName=$(basename "$file" .gmi) sed -e 's/\(=> \)\(.*\)\(.gmi\)\(.*\)/\1\2.html\4/g' \ - -e 's/=> \([^ ]*\) \(.*\)/[\2](\1)\n/g' \ + -e 's/=> \([^ ]*\)\( \|\)\(.*\)/[\3](\1)\n/g' \ + -e 's/\[\](\(.*\))/[\1](\1)/g' \ "$file" > /tmp/sbs/"$fileName".md title=$(grep '^# ' "$file" | head -n1 | cut -d' ' -f2-) description="Page auto-converted from the Gemini format."