2 linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark
3 Copyright (C) 2021-2023 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 Href string `xml:"href,attr"`
30 Owner string `xml:"owner,attr"`
31 Link Link `xml:"link"`
34 type Bookmark struct {
35 Href string `xml:"href,attr"`
36 Title string `xml:"title"`
37 Feeds []Feed `xml:"info>metadata,omitempty"`
41 Title string `xml:"title"`
42 Bookmarks []Bookmark `xml:"bookmark"`
46 XMLName xml.Name `xml:"xbel"`
47 Version string `xml:"version,attr"`
48 Folders []Folder `xml:"folder"`
51 func xbel(cats []string, data map[string][]map[string][]string) {
52 folders := make([]Folder, 0, len(cats))
53 for _, cat := range cats {
55 bs := make([]Bookmark, 0, len(ents))
56 for _, ent := range ents {
57 b := Bookmark{Href: ent["URL"][0], Title: ent["Title"][0]}
58 for _, url := range ent["Feed"] {
59 b.Feeds = append(b.Feeds, Feed{Owner: "webfeed", Link: Link{url}})
63 folders = append(folders, Folder{Title: cat, Bookmarks: bs})
65 x := XBEL{Version: "1.0", Folders: folders}
66 out, err := xml.MarshalIndent(&x, "", " ")
70 os.Stdout.WriteString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
71 os.Stdout.WriteString("<!DOCTYPE xbel>\n")