bibtex.feature 11.9 KB
Newer Older
Sylvester Keil's avatar
Sylvester Keil committed
1
2
3
4
5
Feature: BibTeX
  As a scholar who likes to blog
  I want to publish my BibTeX bibliography on my blog
  In order to share my awesome references with my peers

6
  @converters
Sylvester Keil's avatar
Sylvester Keil committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  Scenario: Simple Bibliography
    Given I have a scholar configuration with:
      | key   | value |
      | style | apa   |
     And I have a page "references.bib":
      """
      ---
      ---
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/references.html" file should exist
    And I should see "<i>The Ruby Programming Language</i>" in "_site/references.html"
Sylvester Keil's avatar
Sylvester Keil committed
26

Sylvester Keil's avatar
Sylvester Keil committed
27
  Scenario: Markdown Formatted Bibliography
28
    Given I have a scholar configuration with:
Sylvester Keil's avatar
Sylvester Keil committed
29
30
31
32
33
34
35
36
      | key   | value |
      | style | apa   |
    And I have a page "references.bib":
      """
      ---
      ---
      References
      ==========
37

Sylvester Keil's avatar
Sylvester Keil committed
38
39
40
41
42
43
44
45
46
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      """
    When I run jekyll
    Then I should see "<h1[^>]*>References</h1>" in "_site/references.html"
Sylvester Keil's avatar
Sylvester Keil committed
47
48

  @latex
Sylvester Keil's avatar
Sylvester Keil committed
49
  Scenario: Simple Bibliography with LaTeX directives
50
    Given I have a scholar configuration with:
Sylvester Keil's avatar
Sylvester Keil committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
      | key   | value |
      | style | apa   |
    And I have a page "references.bib":
      """
      ---
      ---
      @misc{umlaut,
        title     = {Look, an umlaut: \"u!},
      }
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/references.html" file should exist
    And I should see "Look, an umlaut: ü!" in "_site/references.html"
65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  @superscript
  Scenario: Simple Bibliography with LaTeX superscript
    Given I have a scholar configuration with:
      | key   | value |
      | style | apa   |
    And I have a page "references.bib":
      """
      ---
      ---
      @misc{umlaut,
        title     = {Look, \textsuperscript{superscript}!},
      }
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/references.html" file should exist
    And I should see "Look, <sup>superscript</sup>!" in "_site/references.html"

Sylvester Keil's avatar
fix #55    
Sylvester Keil committed
84
  @tags @bibtex
Sylvester Keil's avatar
Sylvester Keil committed
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  Scenario: Embedded BibTeX
    Given I have a scholar configuration with:
      | key   | value |
      | style | apa   |
     And I have a page "references.md":
      """
      ---
      ---
      References
      ==========

      {% bibtex %}
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      {% endbibtex %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/references.html" file should exist
    And I should see "<i>The Ruby Programming Language</i>" in "_site/references.html"

110
  @tags
Sylvester Keil's avatar
Sylvester Keil committed
111
  Scenario: Simple Bibliography Loaded From Default Directory
112
    Given I have a scholar configuration with:
Sylvester Keil's avatar
Sylvester Keil committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
      | key    | value             |
      | source | ./_bibliography   |
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      """
    And I have a page "scholar.html":
      """
      ---
      ---
      {% bibliography -f references %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
135

136
  @tags @bibliography @config @template
Sylvester Keil's avatar
Sylvester Keil committed
137
138
  Scenario: Simple Bibliography With Custom Template
    Given I have a scholar configuration with:
139
140
      | key                   | value                                         |
      | source                | ./_bibliography                               |
141
      | bibliography_template | <abbr>{{index}} {{entry.type}} [{{key}}]</abbr>{{entry.author_1_last}} |
Sylvester Keil's avatar
Sylvester Keil committed
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      """
    And I have a page "scholar.html":
      """
      ---
      ---
      {% bibliography -f references %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
161
    And I should see "<abbr>1 book \[ruby\]</abbr>Matsumoto" in "_site/scholar.html"
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188

  @tags @bibliography @config @template
  Scenario: Simple Bibliography With Custom Template
    Given I have a scholar configuration with:
      | key                   | value                                         |
      | source                | ./_bibliography                               |
      | bibliography_template | <abbr>{{index}} {{entry.type}} [{{key}}]</abbr>{{entry.author_array[1].last}} |
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      """
    And I have a page "scholar.html":
      """
      ---
      ---
      {% bibliography -f references %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should see "<abbr>1 book \[ruby\]</abbr>Matsumoto" in "_site/scholar.html"
Sylvester Keil's avatar
Sylvester Keil committed
189

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
  @tags @bibliography @config @template @names
  Scenario: Simple Bibliography With Custom Template and Name Parsing
    Given I have a scholar configuration with:
      | key                   | value                         |
      | source                | ./_bibliography               |
      | bibliography_template | <span>{{entry.author}}</span> |
    And I have the following BibTeX options:
      | key                   | value  |
      | parse_names           | false  |
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {David Flanagan and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      """
    And I have a page "scholar.html":
      """
      ---
      ---
      {% bibliography -f references %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should see "David Flanagan and Matsumoto, Yukihiro" in "_site/scholar.html"

220
  @tags @filter
Sylvester Keil's avatar
Sylvester Keil committed
221
  Scenario: Filtered Bibliography Loaded From Default Directory
222
    Given I have a scholar configuration with:
Sylvester Keil's avatar
Sylvester Keil committed
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
      | key    | value             |
      | source | ./_bibliography   |
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      },
      @book{smalltalk,
        title     = {Smalltalk Best Practice Patterns},
        author    = {Kent Beck},
        year      = {1996},
        publisher = {Prentice Hall}
      }
240

Sylvester Keil's avatar
Sylvester Keil committed
241
242
243
244
245
246
247
248
249
250
251
252
      """
    And I have a page "scholar.html":
      """
      ---
      ---
      {% bibliography -f references --query @book[year <= 2000] %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
    And I should see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
253

254
  @tags @filter @variables
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
  Scenario: Filter using interpolated query variable
    Given I have a scholar configuration with:
      | key    | value             |
      | source | ./_bibliography   |
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      },
      @book{smalltalk,
        title     = {Smalltalk Best Practice Patterns},
        author    = {Kent Beck},
        year      = {1996},
        publisher = {Prentice Hall}
      }

      """
    And I have a page "scholar.html":
      """
      ---
      ---
      {% assign yr = 2000 %}
      {% bibliography -f references --query @book[year <= {{ yr }}] %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should not see "<i>The Ruby Programming Language</i>" in "_site/scholar.html"
    And I should see "<i>Smalltalk Best Practice Patterns</i>" in "_site/scholar.html"
288
289

  @tags @bibliography @prefix
Sylvester Keil's avatar
Sylvester Keil committed
290
  Scenario: A Prefixed Bibliography
291
    Given I have a scholar configuration with:
Sylvester Keil's avatar
Sylvester Keil committed
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
      | key    | value             |
      | source | ./_bibliography   |
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      },
      @book{smalltalk,
        title     = {Smalltalk Best Practice Patterns},
        author    = {Kent Beck},
        year      = {1996},
        publisher = {Prentice Hall}
      }
309

Sylvester Keil's avatar
Sylvester Keil committed
310
311
312
313
314
315
316
317
318
319
320
321
      """
    And I have a page "scholar.html":
      """
      ---
      ---
      {% bibliography --file references --prefix a -q @book[year <= 2000] %}
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should not see "ruby" in "_site/scholar.html"
    And I should see "id=\"a-smalltalk\"" in "_site/scholar.html"
Sylvester Keil's avatar
Sylvester Keil committed
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341

  @tags @bibliography @style
  Scenario: Simple Bibliography Loaded From Default Directory
    Given I have a scholar configuration with:
      | key    | value             |
      | source | ./_bibliography   |
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language},
        author    = {Flanagan, David and Matsumoto, Yukihiro},
        year      = {2008},
        publisher = {O'Reilly Media}
      }
      """
    And I have a page "scholar.html":
      """
      ---
      ---
Sylvester Keil's avatar
Sylvester Keil committed
342
      {% bibliography  --style modern-language-association %}
Sylvester Keil's avatar
Sylvester Keil committed
343
344
345
346
347
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should see "<i>The Ruby Programming Language</i>. O’Reilly Media, 2008" in "_site/scholar.html"
Sylvester Keil's avatar
Sylvester Keil committed
348
349
350
351
352
353

  @tags @bibliography @config @template
  Scenario: Raw bibtex template
    Given I have a scholar configuration with:
      | key                   | value              |
      | bibliography_template | "{{entry.bibtex}}" |
354
      | use_raw_bibtex_entry  | true               |
Sylvester Keil's avatar
Sylvester Keil committed
355
356
357
358
359
360
361
362
363
364
365
    And I have a "_bibliography" directory
    And I have a file "_bibliography/references.bib":
      """
      @book{ruby,
        title     = {The Ruby Programming Language}
      }
      """
    And I have a page "scholar.html":
      """
      ---
      ---
366
      {% bibliography -f references %}
Sylvester Keil's avatar
Sylvester Keil committed
367
368
369
370
371
      """
    When I run jekyll
    Then the _site directory should exist
    And the "_site/scholar.html" file should exist
    And I should see "{%raw%}@book" in "_site/scholar.html"