File: bm-to-elinks-bookmarks.lua

package info (click to toggle)
elinks 0.19.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,312 kB
  • sloc: ansic: 174,714; cpp: 31,967; sh: 7,841; python: 4,039; perl: 2,183; javascript: 1,794; pascal: 1,720; makefile: 1,006; yacc: 295; lisp: 125; awk: 79; ruby: 70
file content (30 lines) | stat: -rw-r--r-- 704 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/lua -f
-- Convert bm.lua-format bookmarks to ELinks-format bookmarks.
-- Peter Wang, 2002-12-19

prog = arg[0]
infile = arg[1]

if not infile then
    print("Convert bm.lua-format bookmarks to ELinks-format bookmarks.\n")
    print("Usage: " .. prog .. " bookmark.lst")
    print("Output is written to stdout.\n")
    exit(1)
end

bookmarks = dofile(infile)
if type(bookmarks) ~= "table" then
    print("Error loading " .. infile)
    exit(1)
end

function tab2spc(s) return gsub(s, "\t", " ") end -- just in case

for i, cat in bookmarks do
    print(tab2spc(cat.category), "", 0, "FE")

    for i = 1, getn(cat) do
	local bm = cat[i]
	print(tab2spc(bm.name), tab2spc(bm.url), 1)
    end
end