bergamasco 0.1.4 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fbacb25b302f8c6c8e2340e4f41556df70d831e
4
- data.tar.gz: 7b4bfd91c319082d24479e7d946cca90bca038f5
3
+ metadata.gz: c262d6f244868421fee1374c2bba65bc56ffd3d9
4
+ data.tar.gz: 8e9a13b9c80ac8cfb0f3a2fadc0258b95f6345a9
5
5
  SHA512:
6
- metadata.gz: 770d19c32783783fefd5d9813075e0909d59c1b36eef6e18cb4d82dc8a9cab5ea28bc478b6c9457aa3260fc23104e7d6afd920f639e621a888a386ce66b1457f
7
- data.tar.gz: 0b35e1f4104bbfd50b8cf8524ce9d0f750f5e0a99c2c1fde88fdda139b01673ff2b0cde890e23d00ef205dacdbfb8ed520a374757c86eeaccc69b77d6fd11b50
6
+ metadata.gz: b63c233540b52391ceb09fa6e7409754d34ba6f859c9e1abb993303d6f752afe5e31c3cc9a7916857c269b0250a75a28c7078cc5f083a4a1b3cd769c7568f54c
7
+ data.tar.gz: 097034351b04c41224369002826f741c10eadcc9cbf7c2f55d08d35d723ef8e9c2ce598e86114931fae0563128d5979c8b2ad1d2a1f8a930e9a5cab84f34f955
@@ -2,10 +2,15 @@ language: ruby
2
2
  rvm:
3
3
  - 2.3.1
4
4
 
5
+ cache: bundler
6
+
5
7
  before_install:
6
- - sudo add-apt-repository ppa:kalakris/cmake -y
7
- - sudo apt-get update -q
8
- - sudo apt-get install cmake -y
8
+ - wget https://github.com/jgm/pandoc/releases/download/1.15.2/pandoc-1.15.2-1-amd64.deb
9
+ - sudo dpkg -i pandoc-1.15.2-1-amd64.deb
10
+ - rm pandoc-1.15.2-1-amd64.deb
11
+ - sudo add-apt-repository ppa:kalakris/cmake -y
12
+ - sudo apt-get update -q
13
+ - sudo apt-get install cmake -y
9
14
 
10
15
  install:
11
16
  - travis_retry bundle install
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bergamasco (0.1.4)
4
+ bergamasco (0.2.1)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
+ addressable (~> 2.3.8)
6
7
  builder (~> 3.2, >= 3.2.2)
7
8
  commonmarker (~> 0.14.0)
8
9
  loofah (~> 2.0, >= 2.0.3)
@@ -21,6 +22,7 @@ GEM
21
22
  minitest (~> 5.1)
22
23
  thread_safe (~> 0.3, >= 0.3.4)
23
24
  tzinfo (~> 1.1)
25
+ addressable (2.3.8)
24
26
  builder (3.2.2)
25
27
  codeclimate-test-reporter (1.0.3)
26
28
  simplecov
@@ -21,12 +21,13 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'nokogiri', '~> 1.6.7'
22
22
  s.add_dependency 'loofah', '~> 2.0', '>= 2.0.3'
23
23
  s.add_dependency "pandoc-ruby", '~> 2.0', '>= 2.0.0'
24
+ s.add_dependency 'commonmarker', '~> 0.14.0'
24
25
  s.add_dependency 'builder', '~> 3.2', '>= 3.2.2'
25
26
  s.add_dependency 'multi_json', '~> 1.11.2'
26
27
  s.add_dependency 'oj', '~> 2.13.1'
27
28
  s.add_dependency 'activesupport', '~> 4.2', '>= 4.2.5'
28
29
  s.add_dependency 'safe_yaml', '~> 1.0', '>= 1.0.4'
29
- s.add_dependency 'commonmarker', '~> 0.14.0'
30
+ s.add_dependency 'addressable', "~> 2.3.8"
30
31
  s.add_development_dependency 'bundler', '~> 1.0'
31
32
  s.add_development_dependency 'rspec', '~> 3.4'
32
33
  s.add_development_dependency 'rake'
@@ -4,8 +4,11 @@ require 'nokogiri'
4
4
  require 'yaml'
5
5
  require 'safe_yaml/load'
6
6
  require 'loofah'
7
+ require 'pandoc-ruby'
7
8
  require 'commonmarker'
8
9
  require 'pathname'
10
+ require 'time'
11
+ require 'addressable/uri'
9
12
 
10
13
  require "bergamasco/summarize"
11
14
  require "bergamasco/sanitize"
@@ -4,8 +4,10 @@ module Bergamasco
4
4
  YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
5
5
 
6
6
  def self.split_yaml_frontmatter(file)
7
+ return file unless match = YAML_FRONT_MATTER_REGEXP.match(file)
8
+
7
9
  metadata = SafeYAML.load(file)
8
- content = YAML_FRONT_MATTER_REGEXP.match(file).post_match
10
+ content = match.post_match
9
11
  [metadata, content]
10
12
  end
11
13
 
@@ -34,14 +36,58 @@ module Bergamasco
34
36
  SafeYAML.load(file)
35
37
  end
36
38
 
39
+ def self.read_yaml_for_doi_metadata(filepath, options={})
40
+ keys = options[:keys] || ["title", "author", "date", "tags"]
41
+ unless File.exist?(filepath)
42
+ parentdir = Pathname.new(filepath).parent
43
+ FileUtils.mkdir_p parentdir
44
+ FileUtils.touch filepath
45
+ end
46
+
47
+ file = IO.read(filepath)
48
+ yaml = SafeYAML.load(file)
49
+ metadata = yaml.extract!(*keys).compact
50
+
51
+ content = YAML_FRONT_MATTER_REGEXP.match(file).post_match
52
+ html = render_html(content, options)
53
+ metadata["summary"] = Bergamasco::Summarize.summary_from_html(html, options)
54
+ metadata["related_identifiers"] = extract_references(html, options)
55
+ metadata["date"] = metadata["date"].iso8601
56
+ metadata
57
+ end
58
+
37
59
  def self.write_yaml(filepath, content)
38
60
  IO.write(filepath, content.to_yaml)
39
61
  end
40
62
 
41
63
  def self.render_html(text, options={})
64
+ PandocRuby.new(text, options.except(:skip_yaml_header, :separator)).to_html
65
+ rescue Errno::ENOENT
66
+ # fallback to commonmarker if pandoc is not installed.
67
+ # Commonmarker doesn't parse or ignore yaml frontmatter
42
68
  text = split_yaml_frontmatter(text).last if options[:skip_yaml_header]
43
-
44
69
  CommonMarker.render_html(text, :default)
45
70
  end
71
+
72
+ def self.extract_references(html, options={})
73
+ doc = Nokogiri::HTML(html)
74
+ doc.xpath('//div[@id="refs"]/div/@id').map do |ref|
75
+ id = ref.value[4..-1]
76
+
77
+ if /(http|https):\/\/(dx\.)?doi\.org\/(\w+)/.match(id)
78
+ uri = Addressable::URI.parse(id)
79
+ id = uri.path[1..-1].upcase
80
+ type = "DOI"
81
+ else
82
+ type = "URL"
83
+ end
84
+
85
+ {
86
+ id: id,
87
+ related_identifier_type: type,
88
+ relation_type: "references"
89
+ }
90
+ end
91
+ end
46
92
  end
47
93
  end
@@ -11,6 +11,11 @@ module Bergamasco
11
11
  end
12
12
  end
13
13
 
14
+ def self.summary_from_html(html, options={})
15
+ summary = Bergamasco::Sanitize.sanitize(html, options).squish
16
+ summary(summary, options)
17
+ end
18
+
14
19
  # from https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/truncate_html.rb
15
20
  def self.truncate_at_separator(text, separator)
16
21
  text = text.encode('UTF-8') if text.respond_to?(:encode)
@@ -1,3 +1,3 @@
1
1
  module Bergamasco
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,621 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
3
+ <info>
4
+ <title>American Psychological Association 6th edition</title>
5
+ <title-short>APA</title-short>
6
+ <id>http://www.zotero.org/styles/apa</id>
7
+ <link href="http://www.zotero.org/styles/apa" rel="self"/>
8
+ <link href="http://owl.english.purdue.edu/owl/resource/560/01/" rel="documentation"/>
9
+ <author>
10
+ <name>Simon Kornblith</name>
11
+ <email>simon@simonster.com</email>
12
+ </author>
13
+ <contributor>
14
+ <name>Bruce D'Arcus</name>
15
+ </contributor>
16
+ <contributor>
17
+ <name>Curtis M. Humphrey</name>
18
+ </contributor>
19
+ <contributor>
20
+ <name>Richard Karnesky</name>
21
+ <email>karnesky+zotero@gmail.com</email>
22
+ <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
23
+ </contributor>
24
+ <contributor>
25
+ <name>Sebastian Karcher</name>
26
+ </contributor>
27
+ <category citation-format="author-date"/>
28
+ <category field="psychology"/>
29
+ <category field="generic-base"/>
30
+ <updated>2015-10-25T09:01:49+00:00</updated>
31
+ <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
32
+ </info>
33
+ <locale xml:lang="en">
34
+ <terms>
35
+ <term name="editortranslator" form="short">
36
+ <single>ed. &amp; trans.</single>
37
+ <multiple>eds. &amp; trans.</multiple>
38
+ </term>
39
+ <term name="translator" form="short">
40
+ <single>trans.</single>
41
+ <multiple>trans.</multiple>
42
+ </term>
43
+ </terms>
44
+ </locale>
45
+ <macro name="container-contributors">
46
+ <choose>
47
+ <if type="chapter paper-conference entry-dictionary entry-encyclopedia" match="any">
48
+ <group delimiter=", " suffix=", ">
49
+ <names variable="container-author" delimiter=", ">
50
+ <name and="symbol" initialize-with=". " delimiter=", "/>
51
+ <label form="short" prefix=" (" text-case="title" suffix=")"/>
52
+ </names>
53
+ <names variable="editor translator" delimiter=", ">
54
+ <name and="symbol" initialize-with=". " delimiter=", "/>
55
+ <label form="short" prefix=" (" text-case="title" suffix=")"/>
56
+ </names>
57
+ </group>
58
+ </if>
59
+ </choose>
60
+ </macro>
61
+ <macro name="secondary-contributors">
62
+ <choose>
63
+ <if type="article-journal chapter paper-conference entry-dictionary entry-encyclopedia" match="none">
64
+ <group delimiter=", " prefix=" (" suffix=")">
65
+ <names variable="container-author" delimiter=", ">
66
+ <name and="symbol" initialize-with=". " delimiter=", "/>
67
+ <label form="short" prefix=", " text-case="title"/>
68
+ </names>
69
+ <names variable="editor translator" delimiter=", ">
70
+ <name and="symbol" initialize-with=". " delimiter=", "/>
71
+ <label form="short" prefix=", " text-case="title"/>
72
+ </names>
73
+ </group>
74
+ </if>
75
+ </choose>
76
+ </macro>
77
+ <macro name="author">
78
+ <names variable="author">
79
+ <name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with=". " delimiter=", " delimiter-precedes-last="always"/>
80
+ <label form="short" prefix=" (" suffix=")" text-case="capitalize-first"/>
81
+ <substitute>
82
+ <names variable="editor"/>
83
+ <names variable="translator"/>
84
+ <choose>
85
+ <if type="report">
86
+ <text variable="publisher"/>
87
+ <text macro="title"/>
88
+ </if>
89
+ <else>
90
+ <text macro="title"/>
91
+ </else>
92
+ </choose>
93
+ </substitute>
94
+ </names>
95
+ </macro>
96
+ <macro name="author-short">
97
+ <names variable="author">
98
+ <name form="short" and="symbol" delimiter=", " initialize-with=". "/>
99
+ <substitute>
100
+ <names variable="editor"/>
101
+ <names variable="translator"/>
102
+ <choose>
103
+ <if type="report">
104
+ <text variable="publisher"/>
105
+ <text variable="title" form="short" font-style="italic"/>
106
+ </if>
107
+ <else-if type="legal_case">
108
+ <text variable="title" font-style="italic"/>
109
+ </else-if>
110
+ <else-if type="bill book graphic legislation motion_picture song" match="any">
111
+ <text variable="title" form="short" font-style="italic"/>
112
+ </else-if>
113
+ <else-if variable="reviewed-author">
114
+ <choose>
115
+ <if variable="reviewed-title" match="none">
116
+ <text variable="title" form="short" font-style="italic" prefix="Review of "/>
117
+ </if>
118
+ <else>
119
+ <text variable="title" form="short" quotes="true"/>
120
+ </else>
121
+ </choose>
122
+ </else-if>
123
+ <else>
124
+ <text variable="title" form="short" quotes="true"/>
125
+ </else>
126
+ </choose>
127
+ </substitute>
128
+ </names>
129
+ </macro>
130
+ <macro name="access">
131
+ <choose>
132
+ <if type="thesis report" match="any">
133
+ <choose>
134
+ <if variable="archive" match="any">
135
+ <group>
136
+ <text term="retrieved" text-case="capitalize-first" suffix=" "/>
137
+ <text term="from" suffix=" "/>
138
+ <text variable="archive" suffix="."/>
139
+ <text variable="archive_location" prefix=" (" suffix=")"/>
140
+ </group>
141
+ </if>
142
+ <else>
143
+ <group>
144
+ <text term="retrieved" text-case="capitalize-first" suffix=" "/>
145
+ <text term="from" suffix=" "/>
146
+ <text variable="URL"/>
147
+ </group>
148
+ </else>
149
+ </choose>
150
+ </if>
151
+ <else>
152
+ <choose>
153
+ <if variable="DOI">
154
+ <text variable="DOI" prefix="http://doi.org/"/>
155
+ </if>
156
+ <else>
157
+ <choose>
158
+ <if type="webpage">
159
+ <group delimiter=" ">
160
+ <text term="retrieved" text-case="capitalize-first" suffix=" "/>
161
+ <group>
162
+ <date variable="accessed" form="text" suffix=", "/>
163
+ </group>
164
+ <text term="from"/>
165
+ <text variable="URL"/>
166
+ </group>
167
+ </if>
168
+ <else>
169
+ <group>
170
+ <text term="retrieved" text-case="capitalize-first" suffix=" "/>
171
+ <text term="from" suffix=" "/>
172
+ <text variable="URL"/>
173
+ </group>
174
+ </else>
175
+ </choose>
176
+ </else>
177
+ </choose>
178
+ </else>
179
+ </choose>
180
+ </macro>
181
+ <macro name="title">
182
+ <choose>
183
+ <if type="book graphic manuscript motion_picture report song speech thesis" match="any">
184
+ <choose>
185
+ <if variable="version" type="book" match="all">
186
+ <!---This is a hack until we have a computer program type -->
187
+ <text variable="title"/>
188
+ </if>
189
+ <else>
190
+ <text variable="title" font-style="italic"/>
191
+ </else>
192
+ </choose>
193
+ </if>
194
+ <else-if variable="reviewed-author">
195
+ <choose>
196
+ <if variable="reviewed-title">
197
+ <group delimiter=" ">
198
+ <text variable="title"/>
199
+ <group delimiter=", " prefix="[" suffix="]">
200
+ <text variable="reviewed-title" font-style="italic" prefix="Review of "/>
201
+ <names variable="reviewed-author" delimiter=", ">
202
+ <label form="verb-short" suffix=" "/>
203
+ <name and="symbol" initialize-with=". " delimiter=", "/>
204
+ </names>
205
+ </group>
206
+ </group>
207
+ </if>
208
+ <else>
209
+ <!-- assume `title` is title of reviewed work -->
210
+ <group delimiter=", " prefix="[" suffix="]">
211
+ <text variable="title" font-style="italic" prefix="Review of "/>
212
+ <names variable="reviewed-author" delimiter=", ">
213
+ <label form="verb-short" suffix=" "/>
214
+ <name and="symbol" initialize-with=". " delimiter=", "/>
215
+ </names>
216
+ </group>
217
+ </else>
218
+ </choose>
219
+ </else-if>
220
+ <else>
221
+ <text variable="title"/>
222
+ </else>
223
+ </choose>
224
+ </macro>
225
+ <macro name="title-plus-extra">
226
+ <text macro="title"/>
227
+ <choose>
228
+ <if type="report thesis" match="any">
229
+ <group prefix=" (" suffix=")" delimiter=", ">
230
+ <group delimiter=" ">
231
+ <choose>
232
+ <if variable="genre" match="any">
233
+ <text variable="genre"/>
234
+ </if>
235
+ <else>
236
+ <text variable="collection-title"/>
237
+ </else>
238
+ </choose>
239
+ <text variable="number" prefix="No. "/>
240
+ </group>
241
+ <group delimiter=" ">
242
+ <text term="version" text-case="capitalize-first"/>
243
+ <text variable="version"/>
244
+ </group>
245
+ <text macro="edition"/>
246
+ </group>
247
+ </if>
248
+ <else-if type="post-weblog webpage" match="any">
249
+ <text variable="genre" prefix=" [" suffix="]"/>
250
+ </else-if>
251
+ <else-if variable="version">
252
+ <group delimiter=" " prefix=" (" suffix=")">
253
+ <text term="version" text-case="capitalize-first"/>
254
+ <text variable="version"/>
255
+ </group>
256
+ </else-if>
257
+ </choose>
258
+ <text macro="format" prefix=" [" suffix="]"/>
259
+ </macro>
260
+ <macro name="format">
261
+ <choose>
262
+ <if match="any" variable="medium">
263
+ <text variable="medium" text-case="capitalize-first"/>
264
+ </if>
265
+ <else-if type="dataset" match="any">
266
+ <text value="Data set"/>
267
+ </else-if>
268
+ </choose>
269
+ </macro>
270
+ <macro name="publisher">
271
+ <choose>
272
+ <if type="report" match="any">
273
+ <group delimiter=": ">
274
+ <text variable="publisher-place"/>
275
+ <text variable="publisher"/>
276
+ </group>
277
+ </if>
278
+ <else-if type="thesis" match="any">
279
+ <group delimiter=", ">
280
+ <text variable="publisher"/>
281
+ <text variable="publisher-place"/>
282
+ </group>
283
+ </else-if>
284
+ <else-if type="post-weblog webpage" match="none">
285
+ <group delimiter=", ">
286
+ <choose>
287
+ <if variable="event version" type="speech" match="none">
288
+ <!-- Including version is to avoid printing the programming language for computerProgram /-->
289
+ <text variable="genre"/>
290
+ </if>
291
+ </choose>
292
+ <choose>
293
+ <if type="article-journal article-magazine" match="none">
294
+ <group delimiter=": ">
295
+ <choose>
296
+ <if variable="publisher-place">
297
+ <text variable="publisher-place"/>
298
+ </if>
299
+ <else>
300
+ <text variable="event-place"/>
301
+ </else>
302
+ </choose>
303
+ <text variable="publisher"/>
304
+ </group>
305
+ </if>
306
+ </choose>
307
+ </group>
308
+ </else-if>
309
+ </choose>
310
+ </macro>
311
+ <macro name="event">
312
+ <choose>
313
+ <if variable="container-title" match="none">
314
+ <choose>
315
+ <if variable="event">
316
+ <choose>
317
+ <if variable="genre" match="none">
318
+ <text term="presented at" text-case="capitalize-first" suffix=" "/>
319
+ <text variable="event"/>
320
+ </if>
321
+ <else>
322
+ <group delimiter=" ">
323
+ <text variable="genre" text-case="capitalize-first"/>
324
+ <text term="presented at"/>
325
+ <text variable="event"/>
326
+ </group>
327
+ </else>
328
+ </choose>
329
+ </if>
330
+ <else-if type="speech">
331
+ <text variable="genre" text-case="capitalize-first"/>
332
+ </else-if>
333
+ </choose>
334
+ </if>
335
+ </choose>
336
+ </macro>
337
+ <macro name="issued">
338
+ <choose>
339
+ <if type="bill legal_case legislation" match="none">
340
+ <choose>
341
+ <if variable="issued">
342
+ <group prefix=" (" suffix=")">
343
+ <date variable="issued">
344
+ <date-part name="year"/>
345
+ </date>
346
+ <text variable="year-suffix"/>
347
+ <choose>
348
+ <if type="speech" match="any">
349
+ <date variable="issued">
350
+ <date-part prefix=", " name="month"/>
351
+ </date>
352
+ </if>
353
+ <else-if type="article-journal bill book chapter graphic legal_case legislation motion_picture paper-conference report song dataset" match="none">
354
+ <date variable="issued">
355
+ <date-part prefix=", " name="month"/>
356
+ <date-part prefix=" " name="day"/>
357
+ </date>
358
+ </else-if>
359
+ </choose>
360
+ </group>
361
+ </if>
362
+ <else-if variable="status">
363
+ <group prefix=" (" suffix=")">
364
+ <text variable="status"/>
365
+ <text variable="year-suffix" prefix="-"/>
366
+ </group>
367
+ </else-if>
368
+ <else>
369
+ <group prefix=" (" suffix=")">
370
+ <text term="no date" form="short"/>
371
+ <text variable="year-suffix" prefix="-"/>
372
+ </group>
373
+ </else>
374
+ </choose>
375
+ </if>
376
+ </choose>
377
+ </macro>
378
+ <macro name="issued-sort">
379
+ <choose>
380
+ <if type="article-journal bill book chapter graphic legal_case legislation motion_picture paper-conference report song dataset" match="none">
381
+ <date variable="issued">
382
+ <date-part name="year"/>
383
+ <date-part name="month"/>
384
+ <date-part name="day"/>
385
+ </date>
386
+ </if>
387
+ <else>
388
+ <date variable="issued">
389
+ <date-part name="year"/>
390
+ </date>
391
+ </else>
392
+ </choose>
393
+ </macro>
394
+ <macro name="issued-year">
395
+ <choose>
396
+ <if variable="issued">
397
+ <group delimiter="/">
398
+ <date variable="original-date" form="text"/>
399
+ <group>
400
+ <date variable="issued">
401
+ <date-part name="year"/>
402
+ </date>
403
+ <text variable="year-suffix"/>
404
+ </group>
405
+ </group>
406
+ </if>
407
+ <else-if variable="status">
408
+ <text variable="status"/>
409
+ <text variable="year-suffix" prefix="-"/>
410
+ </else-if>
411
+ <else>
412
+ <text term="no date" form="short"/>
413
+ <text variable="year-suffix" prefix="-"/>
414
+ </else>
415
+ </choose>
416
+ </macro>
417
+ <macro name="edition">
418
+ <choose>
419
+ <if is-numeric="edition">
420
+ <group delimiter=" ">
421
+ <number variable="edition" form="ordinal"/>
422
+ <text term="edition" form="short"/>
423
+ </group>
424
+ </if>
425
+ <else>
426
+ <text variable="edition"/>
427
+ </else>
428
+ </choose>
429
+ </macro>
430
+ <macro name="locators">
431
+ <choose>
432
+ <if type="article-journal article-magazine" match="any">
433
+ <group prefix=", " delimiter=", ">
434
+ <group>
435
+ <text variable="volume" font-style="italic"/>
436
+ <text variable="issue" prefix="(" suffix=")"/>
437
+ </group>
438
+ <text variable="page"/>
439
+ </group>
440
+ <choose>
441
+ <!--for advanced online publication-->
442
+ <if variable="issued">
443
+ <choose>
444
+ <if variable="page issue" match="none">
445
+ <text variable="status" prefix=". "/>
446
+ </if>
447
+ </choose>
448
+ </if>
449
+ </choose>
450
+ </if>
451
+ <else-if type="article-newspaper">
452
+ <group delimiter=" " prefix=", ">
453
+ <label variable="page" form="short"/>
454
+ <text variable="page"/>
455
+ </group>
456
+ </else-if>
457
+ <else-if type="book graphic motion_picture report song chapter paper-conference entry-encyclopedia entry-dictionary" match="any">
458
+ <group prefix=" (" suffix=")" delimiter=", ">
459
+ <choose>
460
+ <if type="report" match="none">
461
+ <!-- edition for report is included in title-plus-extra /-->
462
+ <text macro="edition"/>
463
+ </if>
464
+ </choose>
465
+ <choose>
466
+ <if variable="volume" match="any">
467
+ <group>
468
+ <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
469
+ <number variable="volume" form="numeric"/>
470
+ </group>
471
+ </if>
472
+ <else>
473
+ <group>
474
+ <text term="volume" form="short" plural="true" text-case="capitalize-first" suffix=" "/>
475
+ <number variable="number-of-volumes" form="numeric" prefix="1&#8211;"/>
476
+ </group>
477
+ </else>
478
+ </choose>
479
+ <group>
480
+ <label variable="page" form="short" suffix=" "/>
481
+ <text variable="page"/>
482
+ </group>
483
+ </group>
484
+ </else-if>
485
+ <else-if type="legal_case">
486
+ <group prefix=" (" suffix=")" delimiter=" ">
487
+ <text variable="authority"/>
488
+ <date variable="issued" form="text"/>
489
+ </group>
490
+ </else-if>
491
+ <else-if type="bill legislation" match="any">
492
+ <date variable="issued" prefix=" (" suffix=")">
493
+ <date-part name="year"/>
494
+ </date>
495
+ </else-if>
496
+ </choose>
497
+ </macro>
498
+ <macro name="citation-locator">
499
+ <group>
500
+ <choose>
501
+ <if locator="chapter">
502
+ <label variable="locator" form="long" text-case="capitalize-first"/>
503
+ </if>
504
+ <else>
505
+ <label variable="locator" form="short"/>
506
+ </else>
507
+ </choose>
508
+ <text variable="locator" prefix=" "/>
509
+ </group>
510
+ </macro>
511
+ <macro name="container">
512
+ <choose>
513
+ <if type="post-weblog webpage" match="none">
514
+ <group>
515
+ <choose>
516
+ <if type="chapter paper-conference entry-encyclopedia" match="any">
517
+ <text term="in" text-case="capitalize-first" suffix=" "/>
518
+ </if>
519
+ </choose>
520
+ <text macro="container-contributors"/>
521
+ <text macro="secondary-contributors"/>
522
+ <text macro="container-title"/>
523
+ </group>
524
+ </if>
525
+ </choose>
526
+ </macro>
527
+ <macro name="container-title">
528
+ <choose>
529
+ <if type="article article-journal article-magazine article-newspaper" match="any">
530
+ <text variable="container-title" font-style="italic" text-case="title"/>
531
+ </if>
532
+ <else-if type="bill legal_case legislation" match="none">
533
+ <text variable="container-title" font-style="italic"/>
534
+ </else-if>
535
+ </choose>
536
+ </macro>
537
+ <macro name="legal-cites">
538
+ <choose>
539
+ <if type="bill legal_case legislation" match="any">
540
+ <group delimiter=" " prefix=", ">
541
+ <choose>
542
+ <if variable="container-title">
543
+ <text variable="volume"/>
544
+ <text variable="container-title"/>
545
+ <group delimiter=" ">
546
+ <!--change to label variable="section" as that becomes available -->
547
+ <text term="section" form="symbol"/>
548
+ <text variable="section"/>
549
+ </group>
550
+ <text variable="page"/>
551
+ </if>
552
+ <else>
553
+ <choose>
554
+ <if type="legal_case">
555
+ <text variable="number" prefix="No. "/>
556
+ </if>
557
+ <else>
558
+ <text variable="number" prefix="Pub. L. No. "/>
559
+ <group delimiter=" ">
560
+ <!--change to label variable="section" as that becomes available -->
561
+ <text term="section" form="symbol"/>
562
+ <text variable="section"/>
563
+ </group>
564
+ </else>
565
+ </choose>
566
+ </else>
567
+ </choose>
568
+ </group>
569
+ </if>
570
+ </choose>
571
+ </macro>
572
+ <macro name="original-date">
573
+ <choose>
574
+ <if variable="original-date">
575
+ <group prefix="(" suffix=")" delimiter=" ">
576
+ <!---This should be localized-->
577
+ <text value="Original work published"/>
578
+ <date variable="original-date" form="text"/>
579
+ </group>
580
+ </if>
581
+ </choose>
582
+ </macro>
583
+ <citation et-al-min="6" et-al-use-first="1" et-al-subsequent-min="3" et-al-subsequent-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" collapse="year" givenname-disambiguation-rule="primary-name">
584
+ <sort>
585
+ <key macro="author"/>
586
+ <key macro="issued-sort"/>
587
+ </sort>
588
+ <layout prefix="(" suffix=")" delimiter="; ">
589
+ <group delimiter=", ">
590
+ <text macro="author-short"/>
591
+ <text macro="issued-year"/>
592
+ <text macro="citation-locator"/>
593
+ </group>
594
+ </layout>
595
+ </citation>
596
+ <bibliography hanging-indent="true" et-al-min="8" et-al-use-first="6" et-al-use-last="true" entry-spacing="0" line-spacing="2">
597
+ <sort>
598
+ <key macro="author"/>
599
+ <key macro="issued-sort" sort="ascending"/>
600
+ <key macro="title"/>
601
+ </sort>
602
+ <layout>
603
+ <group suffix=".">
604
+ <group delimiter=". ">
605
+ <text macro="author"/>
606
+ <text macro="issued"/>
607
+ <text macro="title-plus-extra"/>
608
+ <text macro="container"/>
609
+ </group>
610
+ <text macro="legal-cites"/>
611
+ <text macro="locators"/>
612
+ <group delimiter=", " prefix=". ">
613
+ <text macro="event"/>
614
+ <text macro="publisher"/>
615
+ </group>
616
+ </group>
617
+ <text macro="access" prefix=" "/>
618
+ <text macro="original-date" prefix=" "/>
619
+ </layout>
620
+ </bibliography>
621
+ </style>