]> Sergey Matveev's repositories - linksexp.git/blobdiff - main.go
Use bugfixed recfile parser
[linksexp.git] / main.go
diff --git a/main.go b/main.go
index cf3ffe574f0ed94d8f9b8b6c13a6d71abcefb127..30f7743a63c5e9f443f8ba2f44567613f41c0210 100644 (file)
--- a/main.go
+++ b/main.go
@@ -1,6 +1,6 @@
 /*
 linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2021-2022 Sergey Matveev <stargrave@stargrave.org>
 
 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
@@ -60,6 +60,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 +128,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 +147,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,
+                               n,
+                               strings.ReplaceAll(ent["URL"][0], "@", "@@"),
+                               strings.ReplaceAll(ent["Title"][0], "@", "@@"),
+                               note,
                                strings.Join(catsOther, ", "),
                        )
                        switch feeds := ent["Feed"]; len(feeds) {
@@ -161,7 +167,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,
+                                       )
                                }
                        }
                }