Improved gmi2map logic
This commit is contained in:
@@ -73,7 +73,7 @@ Note that by default, reflow logic in `gmi2map.sh` is optional and you have to s
|
||||
cat [file] | gmi2map.sh [page_width] [leading_spaces] [trailing_spaces] [placeholder_char]
|
||||
```
|
||||
|
||||
I.e. it looks like the `phlow.sh` and `gopherinfo.sh` options combined, but the spaces part only applies to the reflow, which is also off by default.
|
||||
I.e. it looks like the `phlow.sh` and `gopherinfo.sh` options combined, but the spaces part only applies to the reflow, which is also off by default. Also, it doesn't align the whitespaces after the infolines unless there is non-zero amount of trailing spaces.
|
||||
|
||||
Example - imagine we have this rudimentary Gemtext document in the `example.gmi` file:
|
||||
```
|
||||
@@ -87,19 +87,19 @@ I write a bit longer Gemtext here to showcase reflow capabilities of Bopher Tool
|
||||
See ya!
|
||||
```
|
||||
|
||||
When running `cat example.gmi | bash gmi2map.sh 67`, this file translates to the following Gophermap:
|
||||
When running `cat example.gmi | bash gmi2map.sh 67 0 1`, this file translates to the following Gophermap:
|
||||
|
||||
```
|
||||
$ cat example.gmi | bash gmi2map.sh 67
|
||||
iI write short Gemtext here. ; ; 0
|
||||
i ; ; 0
|
||||
iI write a bit longer Gemtext here to showcase reflow capabilities ; ; 0
|
||||
iof Bopher Tools' gmi2map.sh script, because it really is cool. ; ; 0
|
||||
i ; ; 0
|
||||
iI write short Gemtext here. ; ; 0
|
||||
i ; ; 0
|
||||
iI write a bit longer Gemtext here to showcase reflow capabilities ; ; 0
|
||||
iof Bopher Tools' gmi2map.sh script, because it really is cool. ; ; 0
|
||||
i ; ; 0
|
||||
1Anyway, why not publish it on Gopher? luxferre happynetbox.com 79
|
||||
hOr read my blog on Web... URL:https://chronovir.us ; 0
|
||||
i ; ; 0
|
||||
iSee ya! ; ; 0
|
||||
i ; ; 0
|
||||
iSee ya! ; ; 0
|
||||
.
|
||||
```
|
||||
|
||||
|
||||
+4
-1
@@ -22,8 +22,11 @@ CRLF=$'\r\n'
|
||||
[[ -z "$TSPACES" ]] && TSPACES=0
|
||||
[[ -z "$DELIM" ]] && DELIM=';'
|
||||
|
||||
FORMAT_WIDTH=0 # make formatting width distinct from the target reflow width
|
||||
(( TSPACES > 0 )) && FORMAT_WIDTH="$TARGET_WIDTH" # and only use it if there are trailing spaces
|
||||
|
||||
# format strings to use in different situations:
|
||||
reflowfmt="%-$(( LSPACES ))s%-${TARGET_WIDTH}s%-$(( TSPACES ))s\n" # params: smth, line, smth
|
||||
reflowfmt="%-$(( LSPACES ))s%-${FORMAT_WIDTH}s%-$(( TSPACES ))s\n" # params: smth, line, smth
|
||||
infofmt="i%s${TAB}%s${TAB}%s${TAB}0${CRLF}" # params: line, DELIM, DELIM
|
||||
gopherlinkfmt="%s%s${TAB}%s${TAB}%s${TAB}%d${CRLF}" # params: type, name, selector, host, port
|
||||
extlinkfmt="h%s${TAB}URL:%s${TAB}%s${TAB}0${CRLF}" # params: name, URL, DELIM
|
||||
|
||||
Reference in New Issue
Block a user