-
Notifications
You must be signed in to change notification settings - Fork 0
/
bibhtmltable
executable file
·65 lines (56 loc) · 1.27 KB
/
bibhtmltable
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env ruby
#
# Read bib file and create link output for
# <A HREF="{citeation_key}.pdf">
#
$:.unshift(File.dirname(__FILE__))
require 'bib_library.rb'
require 'papers_library.rb'
require 'getoptlong'
require 'kconv'
require 'date'
require 'ap'
$stdout.set_encoding("UTF-8")
#
# main
#
if __FILE__ == $0
require 'optparse'
opts = { # default options
:mode => "plain",
:draft => false,
:encoding => "UTF-8",
:output_encoding => "UTF-8",
:key_file => "", # if it's null string, try to generate file by basename
:bib_dir => "./bib",
:force => false,
:timestamp => true,
:write => false,
:list => false,
:mismatch_dump => false
}
ARGV.options do |o|
o.banner = "ruby #{$0} [options] BIB_File {cite_keys..}"
o.separator "Options:"
o.parse!
end
if ARGV.size >= 1
blib = BibLibrary.new(ARGV.shift, opts)
cite_keys = blib.keys.sort
if ARGV.size > 0
cite_keys = ARGV
end
cite_keys.each do |ck|
bib = blib[ck]
bib.prep
au = bib.authors || [ ]
f = "#{ck}.pdf"
f.gsub!(/:/, '_')
puts "<tr>"
puts "<td><A HREF=\"#{f}\">#{ck}</td>"
puts "<td>#{bib.title}</td>"
puts "<td>#{au.join(', ')}</td>"
puts "</tr>"
end
end
end