X-Git-Url: http://www.git.stargrave.org/?p=linksexp.git;a=blobdiff_plain;f=main.go;h=f9f7034f5fccca46aeeb259d4a6b508e7cc03bd1;hp=6df487a4d4f5f5304182d0611b30bfe6b6ac9f1b;hb=HEAD;hpb=2922d23b07633b701ac366fcc5f5721ced011a82 diff --git a/main.go b/main.go index 6df487a..5681d3f 100644 --- a/main.go +++ b/main.go @@ -1,19 +1,17 @@ -/* -linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark -Copyright (C) 2021 Sergey Matveev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +// linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark +// Copyright (C) 2021-2024 Sergey Matveev +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . package main @@ -60,6 +58,9 @@ func main() { sort.Strings(m["Category"]) cats := strings.Join(m["Category"], " ") for _, f := range m["Feed"] { + if strings.HasPrefix(f, "gemini://") { + f = "https://gemini/" + f + } fmt.Println(f, cats) } } @@ -125,7 +126,7 @@ func main() { fmt.Println("@menu") fmt.Println("Categories:") for _, cat := range cats { - fmt.Printf("* %s: LinksCat%s\n", cat, cat) + fmt.Printf("* %s (%d items): LinksCat%s\n", cat, len(data[cat]), cat) } fmt.Println("@end menu") @@ -144,11 +145,14 @@ func main() { } var note string if len(ent["Note"]) > 0 { - note = "(" + ent["Note"][0] + ")" + note = "(" + strings.Trim(ent["Note"][0], " \n") + ")" } fmt.Printf( - " @item %d @tab @url{%s, %s} %s @tab %s @tab\n", - n, ent["URL"][0], ent["Title"][0], note, + " @item %d @tab @url{%s,, %s} %s @tab %s @tab\n", + n, + strings.ReplaceAll(ent["URL"][0], "@", "@@"), + strings.ReplaceAll(ent["Title"][0], "@", "@@"), + note, strings.Join(catsOther, ", "), ) switch feeds := ent["Feed"]; len(feeds) { @@ -161,7 +165,10 @@ func main() { ) default: for i, feed := range feeds { - fmt.Printf(" @url{%s, feed%d}\n", feed, i) + fmt.Printf( + " @url{%s, feed%d}\n", + strings.ReplaceAll(feed, "@", "@@"), i, + ) } } }