bibtex-ruby 4.4.3 → 4.4.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bibtex-ruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/bibtex/name_parser.rb +37 -37
- data/lib/bibtex/names.y +1 -1
- data/lib/bibtex/version.rb +1 -1
- data/test/bibtex/test_name_parser.rb +5 -1
- data/test/bibtex/test_parser.rb +45 -29
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b875bae176a9021f96347ab6c87ac0b9602c429
|
4
|
+
data.tar.gz: 6beccf8dbef2c6f4462ad9ada4f15a8d71981019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2cea409d83b8610f24d22e31fa190ac6480d21a2380edd955d377a2491b64baa39fc14655a04241ea4f94e03c77feca143400d4d23bb490fa0a4e47aabdefc0
|
7
|
+
data.tar.gz: 7555dc7ca3e8095b4cd2fa0e1e46d2ea570086792ca59039fd16e7c661102c8cfcc1870f81c19302c91360ceda932099231ecb9541b2b32d163aab130f6eda88
|
data/Gemfile
CHANGED
data/lib/bibtex/name_parser.rb
CHANGED
@@ -50,7 +50,7 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 116)
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def on_error(tid, val, vstack)
|
53
|
-
BibTeX.log.
|
53
|
+
BibTeX.log.debug("Failed to parse BibTeX Name on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
|
54
54
|
end
|
55
55
|
|
56
56
|
def scan(input)
|
@@ -168,34 +168,34 @@ module_eval(<<'...end names.y/module_eval...', 'names.y', 116)
|
|
168
168
|
##### State transition tables begin ###
|
169
169
|
|
170
170
|
racc_action_table = [
|
171
|
-
-
|
172
|
-
-
|
173
|
-
-
|
174
|
-
-
|
175
|
-
25, -26, 24,
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
171
|
+
-22, 6, -25, -24, 42, -37, -22, -22, 56, -24,
|
172
|
+
-24, -37, -37, -37, 42, -25, -38, 34, -39, -37,
|
173
|
+
-37, -24, -38, -38, -39, -39, 54, -24, -24, -22,
|
174
|
+
26, -25, -20, -20, -20, -22, -22, -26, 24, 51,
|
175
|
+
25, -26, 24, 40, 25, 24, 43, 25, 49, 48,
|
176
|
+
50, 49, 48, 50, 24, 37, 25, 49, 48, 50,
|
177
|
+
16, 14, 17, 24, 23, 25, 49, 48, 50, 16,
|
178
|
+
29, 17, 24, 32, 25, 24, 37, 25, 24, 32,
|
179
|
+
25, 49, 48, 50, 4, 5, 4, 5, 54 ]
|
180
180
|
|
181
181
|
racc_action_check = [
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
37,
|
186
|
-
21,
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
182
|
+
23, 1, 23, 51, 36, 29, 23, 23, 45, 51,
|
183
|
+
51, 29, 29, 14, 31, 14, 16, 13, 17, 14,
|
184
|
+
14, 40, 16, 16, 17, 17, 53, 40, 40, 37,
|
185
|
+
6, 37, 32, 32, 32, 37, 37, 38, 38, 38,
|
186
|
+
38, 21, 21, 21, 21, 33, 33, 33, 34, 34,
|
187
|
+
34, 42, 42, 42, 20, 20, 20, 56, 56, 56,
|
188
|
+
4, 4, 4, 5, 5, 5, 54, 54, 54, 10,
|
189
|
+
10, 10, 11, 11, 11, 39, 39, 39, 28, 28,
|
190
|
+
28, 47, 47, 47, 0, 0, 2, 2, 41 ]
|
191
191
|
|
192
192
|
racc_action_pointer = [
|
193
|
-
|
194
|
-
|
195
|
-
51,
|
196
|
-
nil, 12,
|
197
|
-
21,
|
198
|
-
nil,
|
193
|
+
78, 1, 80, nil, 57, 60, 30, nil, nil, nil,
|
194
|
+
66, 69, nil, 15, 13, nil, 16, 18, nil, nil,
|
195
|
+
51, 39, nil, 0, nil, nil, nil, nil, 75, 5,
|
196
|
+
nil, 12, 29, 42, 45, nil, 2, 29, 35, 72,
|
197
|
+
21, 86, 48, nil, nil, 6, nil, 78, nil, nil,
|
198
|
+
nil, 3, nil, 24, 63, nil, 54, nil, nil, nil ]
|
199
199
|
|
200
200
|
racc_action_default = [
|
201
201
|
-1, -40, -2, -3, -40, -40, -40, -4, -5, -7,
|
@@ -206,22 +206,22 @@ racc_action_default = [
|
|
206
206
|
-39, -21, -14, -40, -35, -17, -35, -34, -18, -28 ]
|
207
207
|
|
208
208
|
racc_goto_table = [
|
209
|
-
9, 10, 21, 19,
|
210
|
-
|
211
|
-
|
212
|
-
nil, nil,
|
213
|
-
|
209
|
+
9, 10, 21, 19, 30, 31, 27, 3, 44, 7,
|
210
|
+
12, 22, 1, 59, 36, 30, 55, 38, 35, 2,
|
211
|
+
8, 18, 41, 11, 20, nil, nil, 30, 58, 28,
|
212
|
+
nil, nil, 30, 53, nil, nil, 38, 52, nil, nil,
|
213
|
+
39, nil, nil, 57 ]
|
214
214
|
|
215
215
|
racc_goto_check = [
|
216
|
-
6, 7, 7, 11,
|
217
|
-
|
218
|
-
|
219
|
-
nil, nil, 9,
|
220
|
-
|
216
|
+
6, 7, 7, 11, 14, 9, 6, 3, 12, 3,
|
217
|
+
10, 10, 1, 13, 9, 14, 12, 7, 11, 2,
|
218
|
+
4, 5, 9, 8, 8, nil, nil, 14, 12, 8,
|
219
|
+
nil, nil, 14, 9, nil, nil, 7, 11, nil, nil,
|
220
|
+
8, nil, nil, 6 ]
|
221
221
|
|
222
222
|
racc_goto_pointer = [
|
223
|
-
nil,
|
224
|
-
|
223
|
+
nil, 12, 19, 7, 16, 16, -4, -3, 19, -6,
|
224
|
+
6, -2, -26, -43, -6, nil ]
|
225
225
|
|
226
226
|
racc_goto_default = [
|
227
227
|
nil, nil, nil, nil, nil, nil, 46, 33, nil, 13,
|
data/lib/bibtex/names.y
CHANGED
@@ -151,7 +151,7 @@ require 'strscan'
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def on_error(tid, val, vstack)
|
154
|
-
BibTeX.log.
|
154
|
+
BibTeX.log.debug("Failed to parse BibTeX Name on value %s (%s) %s" % [val.inspect, token_to_str(tid) || '?', vstack.inspect])
|
155
155
|
end
|
156
156
|
|
157
157
|
def scan(input)
|
data/lib/bibtex/version.rb
CHANGED
data/test/bibtex/test_parser.rb
CHANGED
@@ -2,21 +2,21 @@ require 'helper.rb'
|
|
2
2
|
|
3
3
|
module BibTeX
|
4
4
|
class ParserTest < Minitest::Spec
|
5
|
-
|
5
|
+
|
6
6
|
describe 'given a set of valid @entries' do
|
7
7
|
before do
|
8
8
|
@bib = Parser.new(:debug => false).parse(File.read(Test.fixtures(:entry)))
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it 'returns a Bibliography instance' do
|
12
12
|
assert @bib
|
13
13
|
refute @bib.empty?
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it 'parses all entries' do
|
17
17
|
assert_equal 4, @bib.length
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it 'parses the key values' do
|
21
21
|
assert_equal %w{ key:0 key:1 foo staudinger }, @bib.map(&:key)
|
22
22
|
end
|
@@ -24,22 +24,22 @@ module BibTeX
|
|
24
24
|
it 'should parse the entry types' do
|
25
25
|
assert_equal [:book, :article, :article, :commentary], @bib.map(&:type)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it 'should parse all values correctly' do
|
29
29
|
assert_equal 'Poe, Edgar A.', @bib[:'key:0'].author.to_s
|
30
30
|
assert_equal 'Hawthorne, Nathaniel', @bib[:'key:1'].author.to_s
|
31
|
-
|
31
|
+
|
32
32
|
assert_equal '2003', @bib[:'key:0'].year
|
33
33
|
assert_equal '2001', @bib[:'key:1'].year
|
34
34
|
|
35
35
|
assert_equal 'American Library', @bib[:'key:0'].publisher
|
36
36
|
assert_equal 'American Library', @bib[:'key:1'].publisher
|
37
|
-
|
37
|
+
|
38
38
|
assert_equal %q[Selected \emph{Poetry} and `Tales'], @bib[:'key:0'].title
|
39
39
|
assert_equal 'Tales and Sketches', @bib[:'key:1'].title
|
40
|
-
end
|
40
|
+
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
describe 'key parsing' do
|
44
44
|
it 'handles whitespace in keys' do
|
45
45
|
input = "@Misc{George Martin06,title = {FEAST FOR CROWS}}"
|
@@ -63,30 +63,30 @@ module BibTeX
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'fails when there is no cite-key' do
|
66
|
-
input = "@misc{title = {Crime and Punishment}}"
|
66
|
+
input = "@misc{title = {Crime and Punishment}}"
|
67
67
|
assert_raises ParseError do
|
68
68
|
Parser.new(:debug => false, :strict => false).parse(input)
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it 'tolerates missing key with :allow_missing_keys set' do
|
73
|
-
input = "@misc{title = {Crime and Punishment}}"
|
73
|
+
input = "@misc{title = {Crime and Punishment}}"
|
74
74
|
assert_equal :misc, Parser.new({
|
75
75
|
:debug => false, :strict => false, :allow_missing_keys => true
|
76
76
|
}).parse(input)[0].type
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
describe 'backslashes and escape sequences' do
|
81
|
-
|
81
|
+
|
82
82
|
it 'leaves backslashes intact' do
|
83
83
|
Parser.new.parse(%q(@misc{key, title = "a backslash: \"}))[0].title.must_be :==, 'a backslash: \\'
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
it 'parses LaTeX escaped quotes {"}' do
|
87
87
|
Parser.new.parse(%q(@misc{key, title = "{"}"}))[0].title.must_be :==, '{"}'
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
it 'parses complex LaTeX markup' do
|
91
91
|
b = Parser.new.parse(<<-END)[0]
|
92
92
|
@book{proust_1996,
|
@@ -103,14 +103,14 @@ module BibTeX
|
|
103
103
|
b.booktitle.must_be :==, "Perception et Intermodalit\\'{e}: Approches Actuelles De La Question De Molyneux"
|
104
104
|
b.editor.to_s.must_be :==, 'Proust, Jo\"{e}lle'
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
describe 'given a set of explicit and implicit comments' do
|
110
110
|
before do
|
111
111
|
@bib = Parser.new(:debug => false, :include => [:meta_content]).parse(File.read(Test.fixtures(:comment)))
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
it 'should parses all @comments' do
|
115
115
|
assert_equal 2, @bib.comments.length
|
116
116
|
end
|
@@ -118,35 +118,35 @@ module BibTeX
|
|
118
118
|
it 'should parses all meta content' do
|
119
119
|
assert_equal 3, @bib.meta_contents.length
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
it 'should parse @comment content as string' do
|
123
123
|
assert_equal ' A comment can contain pretty much anything ', @bib.comments[0].content
|
124
124
|
assert_equal %Q[\n@string{ foo = "bar" }\n\n@string{ bar = "foo" }\n], @bib.comments[1].content
|
125
|
-
end
|
125
|
+
end
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
describe 'given a set of @preambles' do
|
129
129
|
before do
|
130
130
|
@bib = Parser.new(:debug => false).parse(File.read(Test.fixtures(:preamble)))
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
it 'should parse all @preambles' do
|
134
134
|
assert_equal 3, @bib.preambles.length
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
it 'should parse all contents' do
|
138
138
|
assert_equal 'This bibliography was created \\today', @bib.preambles[0].value.to_s
|
139
139
|
assert_equal 'Bib\\TeX', @bib.preambles[1].value.to_s
|
140
140
|
assert_equal '"Maintained by " # maintainer', @bib.preambles[2].value.to_s
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
describe 'given an entry containing a multi-line literals' do
|
145
145
|
before do
|
146
146
|
@braces = %Q[@TechReport{key,\n author = {Donald,\n Duck}\n}]
|
147
147
|
@string = %Q[@TechReport{key,\n author = "Donald,\n Duck"\n}]
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
it 'should parse string literals' do
|
151
151
|
refute_nil Parser.new.parse(@string)[:key]
|
152
152
|
end
|
@@ -156,7 +156,7 @@ module BibTeX
|
|
156
156
|
end
|
157
157
|
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
describe 'year values' do
|
161
161
|
it 'parses non-numeric year literals' do
|
162
162
|
assert_equal 'to appear',
|
@@ -174,11 +174,11 @@ module BibTeX
|
|
174
174
|
@level = BibTeX.log.level
|
175
175
|
BibTeX.log.level = Logger::FATAL
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
after do
|
179
179
|
BibTeX.log.level = @level
|
180
180
|
end
|
181
|
-
|
181
|
+
|
182
182
|
it 'raises a parser error' do
|
183
183
|
lambda {
|
184
184
|
Parser.new.parse <<-END
|
@@ -190,5 +190,21 @@ module BibTeX
|
|
190
190
|
}.must_raise(ParseError)
|
191
191
|
end
|
192
192
|
end
|
193
|
+
|
194
|
+
describe 'given an entry with empty values' do
|
195
|
+
it 'does not raise an error' do
|
196
|
+
bib = BibTeX.parse <<-END
|
197
|
+
@Incollection{test,
|
198
|
+
author = {author},
|
199
|
+
title = {title},
|
200
|
+
editor = {},
|
201
|
+
}
|
202
|
+
END
|
203
|
+
|
204
|
+
assert_equal 'author', bib[:test][:author]
|
205
|
+
assert_equal 'title', bib[:test][:title]
|
206
|
+
assert_equal '', bib[:test][:editor]
|
207
|
+
end
|
208
|
+
end
|
193
209
|
end
|
194
210
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibtex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: latex-decode
|
@@ -145,22 +145,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.6.
|
148
|
+
rubygems_version: 2.6.12
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: A BibTeX parser, converter and API for Ruby.
|
152
152
|
test_files:
|
153
|
-
- test/bibtex/
|
153
|
+
- test/bibtex/entry/test_rdf_converter.rb
|
154
|
+
- test/bibtex/test_bibliography.rb
|
155
|
+
- test/bibtex/test_elements.rb
|
156
|
+
- test/bibtex/test_entry.rb
|
157
|
+
- test/bibtex/test_filters.rb
|
154
158
|
- test/bibtex/test_lexer.rb
|
159
|
+
- test/bibtex/test_name_parser.rb
|
155
160
|
- test/bibtex/test_names.rb
|
156
161
|
- test/bibtex/test_parser.rb
|
157
|
-
- test/bibtex/test_bibliography.rb
|
158
|
-
- test/bibtex/test_filters.rb
|
159
|
-
- test/bibtex/test_utilities.rb
|
160
162
|
- test/bibtex/test_string.rb
|
161
|
-
- test/bibtex/
|
162
|
-
- test/bibtex/
|
163
|
-
- test/bibtex/test_elements.rb
|
164
|
-
- test/bibtex/entry/test_rdf_converter.rb
|
163
|
+
- test/bibtex/test_utilities.rb
|
164
|
+
- test/bibtex/test_value.rb
|
165
165
|
- test/test_bibtex.rb
|
166
166
|
- test/test_export.rb
|