1 // linksexp -- Texinfo/XBEL/OPML/urls autogeneration from recfile bookmark
2 // Copyright (C) 2021-2024 Sergey Matveev <stargrave@stargrave.org>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, version 3 of the License.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
25 Type string `xml:"type,attr"`
26 Text string `xml:"text,attr"`
27 XmlUrl string `xml:"xmlUrl,attr"`
28 HtmlUrl string `xml:"htmlUrl,attr"`
29 Category string `xml:"category,attr,omitempty"`
33 XMLName xml.Name `xml:"opml"`
34 Version string `xml:"version,attr"`
35 Head string `xml:"head"`
36 Outlines []Outline `xml:"body>outline"`
39 func opml(data []map[string][]string) {
40 outlines := make([]Outline, 0, len(data))
41 for _, ent := range data {
42 for _, feed := range ent["Feed"] {
43 outlines = append(outlines, Outline{
45 Text: ent["Title"][0],
46 HtmlUrl: ent["URL"][0],
48 Category: strings.Join(ent["Category"], ","),
52 x := OPML{Version: "2.0", Outlines: outlines}
53 out, err := xml.MarshalIndent(&x, "", " ")
57 os.Stdout.WriteString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")