citeproc-ruby 1.1.7 → 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/BSDL +1 -1
  3. data/Gemfile +10 -32
  4. data/README.md +5 -2
  5. data/lib/citeproc/ruby.rb +1 -0
  6. data/lib/citeproc/ruby/format.rb +1 -1
  7. data/lib/citeproc/ruby/formats/latex.rb +136 -0
  8. data/lib/citeproc/ruby/renderer.rb +2 -1
  9. data/lib/citeproc/ruby/renderer/date.rb +9 -4
  10. data/lib/citeproc/ruby/renderer/format.rb +1 -0
  11. data/lib/citeproc/ruby/version.rb +1 -1
  12. metadata +18 -88
  13. data/.rspec +0 -3
  14. data/.rubocop.yml +0 -1156
  15. data/.simplecov +0 -4
  16. data/Guardfile +0 -14
  17. data/features/bibliography.feature +0 -25
  18. data/features/locale_overrides.feature +0 -31
  19. data/features/name_options.feature +0 -37
  20. data/features/names.feature +0 -198
  21. data/features/renderer.feature +0 -94
  22. data/features/sort.feature +0 -50
  23. data/features/step_definitions/engine.rb +0 -21
  24. data/features/step_definitions/renderer.rb +0 -85
  25. data/features/style_immanent_locale_terms.feature +0 -30
  26. data/features/support/env.rb +0 -35
  27. data/features/support/hooks.rb +0 -10
  28. data/spec/citeproc/ruby/engine_spec.rb +0 -120
  29. data/spec/citeproc/ruby/formats/default_spec.rb +0 -168
  30. data/spec/citeproc/ruby/formats/html_spec.rb +0 -167
  31. data/spec/citeproc/ruby/renderer/choose_spec.rb +0 -293
  32. data/spec/citeproc/ruby/renderer/date_spec.rb +0 -173
  33. data/spec/citeproc/ruby/renderer/group_spec.rb +0 -114
  34. data/spec/citeproc/ruby/renderer/history_spec.rb +0 -47
  35. data/spec/citeproc/ruby/renderer/label_spec.rb +0 -225
  36. data/spec/citeproc/ruby/renderer/layout_spec.rb +0 -41
  37. data/spec/citeproc/ruby/renderer/macro_spec.rb +0 -31
  38. data/spec/citeproc/ruby/renderer/names_spec.rb +0 -396
  39. data/spec/citeproc/ruby/renderer/number_spec.rb +0 -120
  40. data/spec/citeproc/ruby/renderer/text_spec.rb +0 -125
  41. data/spec/citeproc/ruby/renderer_spec.rb +0 -65
  42. data/spec/fixtures/items.rb +0 -113
  43. data/spec/fixtures/locales/locales-de-DE.xml +0 -298
  44. data/spec/fixtures/locales/locales-en-US.xml +0 -304
  45. data/spec/fixtures/locales/locales-fr-FR.xml +0 -317
  46. data/spec/fixtures/styles/apa-with-different-translations.csl +0 -451
  47. data/spec/fixtures/styles/apa.csl +0 -443
  48. data/spec/fixtures/styles/modern-language-association-8th-edition.csl +0 -293
  49. data/spec/spec_helper.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f90413e1dbdad9d8cac2857be117f5d9809a237f
4
- data.tar.gz: 04d4e2ff034c9135fb8d9052cdba79c6a0167443
2
+ SHA256:
3
+ metadata.gz: 014be42d1ff5edb75e72427a8319c67fa9b608abf2723405dff4f796af208aba
4
+ data.tar.gz: 31df98d0db8076dada231773cd635c00d82a809cb44e27ff495954696bc5b99b
5
5
  SHA512:
6
- metadata.gz: 7f310cb1e6b84029c4e47a7911d4a8b625ac4219ac57a68b260b8c8cdba42b04c1d7ccda6c163fe9a066006defb0ff33ea21ab73cbbc3f9bfa5b2fbb0fb6ff35
7
- data.tar.gz: 5472220e35ea73e9957579336532ca6c4a7b6c0ddebb53b416fd53114338756e98008a6e3e5ac2bbe7716d773ef71383bec05411cc6895aa26150944c76dd6e0
6
+ metadata.gz: d990699b91c3f73999a4c6110aa1261e1b78add8e3ed2be5ad72db2f5285a7fc8ab549b58e55824ba38fa47bb5f1057c5e0235337b25b27922a74137ff97a847
7
+ data.tar.gz: 0a5a2481dbca2898accf816703705152f2f9d7880c06e347b29b478177c71ab1cccc3d0608d2618e61008ed8e7a5bba2d08dffb88354c3b1fb41367088de219b
data/BSDL CHANGED
@@ -1,7 +1,7 @@
1
1
  CiteProc-Ruby. A Ruby CSL cite processor.
2
2
 
3
3
  Copyright 2012 President and Fellows of Harvard College.
4
- Copyright 2009-2016 Sylvester Keil. All rights reserved.
4
+ Copyright 2009-2020 Sylvester Keil. All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without
7
7
  modification, are permitted provided that the following conditions are met:
data/Gemfile CHANGED
@@ -5,51 +5,29 @@ gemspec
5
5
  #gem 'csl', :github => 'inukshuk/csl-ruby'
6
6
 
7
7
  group :development, :test do
8
- gem 'rake', '~>10.0'
9
- gem 'rspec', '~>3.0', '<3.2.0'
10
- gem 'cucumber', '~>2.3'
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'cucumber'
11
+ gem 'unicode_utils', require: false unless RUBY_VERSION >= '2.4'
11
12
  end
12
13
 
13
14
  group :debug do
14
- if RUBY_VERSION >= '2.0'
15
- gem 'byebug', :require => false, :platforms => :mri
16
- else
17
- gem 'debugger', :require => false, :platforms => :mri
18
- end
19
-
15
+ gem 'byebug', :require => false, :platforms => :mri
20
16
  gem 'ruby-debug', :require => false, :platforms => :jruby
21
-
22
- gem 'rubinius-debugger', :require => false, :platforms => :rbx
23
- gem 'rubinius-compiler', :require => false, :platforms => :rbx
24
17
  end
25
18
 
26
19
  group :optional do
27
- if RUBY_VERSION >= '2.2.2'
28
- gem 'edtf', '~>3.0'
29
- else
30
- gem 'edtf', '~>2.0'
31
- end
20
+ gem 'edtf'
32
21
  gem 'chronic'
33
22
  end
34
23
 
35
24
  group :extra do
36
- gem 'guard', '~>2.2'
37
- gem 'guard-rspec'
38
- gem 'guard-cucumber'
39
- gem 'rb-fsevent'
40
25
  gem 'pry'
41
- gem 'yard', '~>0.8', :platforms => :mri
42
- gem 'redcarpet', '~>3.0', :platforms => :mri
26
+ gem 'yard', platforms: :mri
27
+ gem 'redcarpet', platforms: :mri
43
28
  end
44
29
 
45
30
  group :coverage do
46
- gem 'simplecov', '~>0.8'
47
- gem 'rubinius-coverage', :platforms => :rbx
48
- gem 'coveralls', :require => false
49
- end
50
-
51
- group :rbx do
52
- gem 'rubysl', :platforms => :rbx
53
- gem 'racc', :platforms => :rbx
54
- gem 'json', '~>1.8', :platforms => :rbx
31
+ gem 'simplecov', require: false
32
+ gem 'coveralls', require: false if ENV['CI']
55
33
  end
data/README.md CHANGED
@@ -8,7 +8,6 @@ cite processor, please refer to the documentation of the
8
8
 
9
9
  [![Build Status](https://secure.travis-ci.org/inukshuk/citeproc-ruby.png)](http://travis-ci.org/inukshuk/citeproc-ruby)
10
10
  [![Coverage Status](https://coveralls.io/repos/github/inukshuk/citeproc-ruby/badge.svg?branch=master)](https://coveralls.io/github/inukshuk/citeproc-ruby?branch=master)
11
- [![Dependency Status](https://gemnasium.com/badges/github.com/inukshuk/citeproc-ruby.svg)](https://gemnasium.com/github.com/inukshuk/citeproc-ruby)
12
11
  [![Code Climate](https://codeclimate.com/github/inukshuk/citeproc-ruby/badges/gpa.svg)](https://codeclimate.com/github/inukshuk/citeproc-ruby)
13
12
 
14
13
  Quickstart
@@ -76,6 +75,10 @@ Start rendering you references with any CSL style!
76
75
  # You can also render citations on the fly.
77
76
  cp.render :citation, id: 'knuth', locator: '23'
78
77
  #-> (Knuth, 1968, p. 23)
78
+
79
+ # Pass an array if you want to render multiple citations:
80
+ cp.render :citation, [{ id: 'knuth' }, { id: 'perez' }]
81
+ #-> (Knuth, 1968; Perez, 1989)
79
82
 
80
83
  Documentation
81
84
  -------------
@@ -147,7 +150,7 @@ this project as part of [Google Summer of Code](https://developers.google.com/op
147
150
 
148
151
  Copyright
149
152
  ---------
150
- Copyright 2009-2016 Sylvester Keil. All rights reserved.
153
+ Copyright 2009-2020 Sylvester Keil. All rights reserved.
151
154
 
152
155
  Copyright 2012 President and Fellows of Harvard College.
153
156
 
@@ -9,6 +9,7 @@ require 'citeproc/ruby/format'
9
9
 
10
10
  require 'citeproc/ruby/formats/default'
11
11
  require 'citeproc/ruby/formats/html'
12
+ require 'citeproc/ruby/formats/latex'
12
13
 
13
14
  require 'citeproc/ruby/renderer'
14
15
 
@@ -198,7 +198,7 @@ module CiteProc
198
198
  end
199
199
 
200
200
  def split_closing_quotes(string)
201
- string.split(/([#{close_inner_quote}#{close_quote}]+)$/, 2)
201
+ string.split(/((#{Regexp.quote(close_inner_quote)}|#{Regexp.quote(close_quote)})+)$/, 2)
202
202
  end
203
203
 
204
204
  def apply_quotes
@@ -0,0 +1,136 @@
1
+ module CiteProc
2
+ module Ruby
3
+ module Formats
4
+
5
+ class Latex < Format
6
+
7
+ @defaults = {
8
+ :italic => 'emph', # em
9
+ :bold => 'textbf', # strong
10
+ :container => '', # inner container
11
+ :display => '' # display container
12
+ }
13
+
14
+ @vertical_align = Hash.new { |_,k| k }
15
+ @vertical_align['sup'] = 'super'
16
+
17
+ class << self
18
+ attr_reader :defaults
19
+ end
20
+
21
+ attr_reader :config
22
+
23
+ def initialize(config = nil)
24
+ if config.nil?
25
+ @config = Latex.defaults.dup
26
+ else
27
+ @config = Latex.defaults.merge(config)
28
+ end
29
+ end
30
+
31
+ def bibliography(bibliography)
32
+ bibliography.header = "\\begin{enumerate}"
33
+ bibliography.footer = "\\end{enumerate}"
34
+
35
+ bibliography.prefix = "\\item "
36
+ bibliography.suffix = ""
37
+
38
+ bibliography.connector = "\n"
39
+ bibliography
40
+ end
41
+
42
+ def apply_font_style
43
+ if options[:'font-style'] == 'italic'
44
+ output.replace content_tag(config[:italic], output)
45
+ end
46
+ end
47
+
48
+ def apply_font_variant
49
+ end
50
+
51
+ def apply_font_weight
52
+ if options[:'font-weight'] == 'bold'
53
+ output.replace content_tag(config[:bold], output)
54
+ end
55
+ end
56
+
57
+ def apply_text_decoration
58
+ end
59
+
60
+ def apply_vertical_align
61
+ end
62
+
63
+ def apply_display
64
+ output.replace(
65
+ content_tag(config[:display], output)
66
+ )
67
+ end
68
+
69
+ def escape_quotes?
70
+ false
71
+ end
72
+
73
+ protected
74
+
75
+ def finalize!
76
+ # TODO find a better solution for this (strip tags?)
77
+ # For now make sure not to double encode entities
78
+ # by matching spaces before or after.
79
+ output.gsub!(/[$&#^_%~]/) do |c|
80
+ case c
81
+ # TODO: when "\\" then '\backslash{}'
82
+ when "^" then '\^{}'
83
+ when '~' then '\~{}'
84
+ else "\\#{c}"
85
+ end
86
+ end
87
+ end
88
+
89
+ def cleanup!
90
+ super
91
+ end
92
+
93
+ private
94
+
95
+ def content_tag(name, content, options = nil)
96
+ opening_tag(name, options) << content << closing_tag(name)
97
+ end
98
+
99
+ def style_for(options)
100
+ return unless options && !options.empty?
101
+ options.map { |*kv| kv.join(': ') }.join('; ')
102
+ end
103
+
104
+ def attribute_assignments(options)
105
+ return unless options
106
+
107
+ options = options.select { |_, v| !v.nil? }
108
+
109
+ return unless !options.empty?
110
+
111
+ ' ' << options.map { |k, v| [k, v.inspect].join('=') }.join(' ')
112
+ end
113
+
114
+ def opening_tag(name, options = nil)
115
+ if options && options.key?('style')
116
+ options['style'] = style_for(options['style'])
117
+ end
118
+
119
+ if name == ''
120
+ ''
121
+ else
122
+ "\\#{name}{"
123
+ end
124
+ end
125
+
126
+ def closing_tag(name)
127
+ if name == ''
128
+ ''
129
+ else
130
+ '}'
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -15,7 +15,8 @@ module CiteProc
15
15
  @engine = options_or_engine
16
16
  when Hash
17
17
  locale, format = options_or_engine.values_at(:locale, :format)
18
- @locale, @format = CSL::Locale.load(locale), Format.load(format)
18
+ @locale = locale.is_a?(CSL::Locale) ? locale : CSL::Locale.load(locale)
19
+ @format = Format.load(format)
19
20
  end
20
21
  end
21
22
 
@@ -74,10 +74,15 @@ module CiteProc
74
74
  year = date.year
75
75
  year = year % 100 if node.short?
76
76
 
77
- year = year.to_s
78
-
79
- year << translate(:ad) if date.ad?
80
- year << translate(:ad) if date.ad?
77
+ if date.ad?
78
+ year = year.to_s
79
+ year << translate(:ad) if date.ad?
80
+ elsif date.bc?
81
+ year = (-1*year).to_s
82
+ year << translate(:bc) if date.bc?
83
+ else
84
+ year = year.to_s
85
+ end
81
86
 
82
87
  year
83
88
 
@@ -60,6 +60,7 @@ module CiteProc
60
60
 
61
61
  def format_page_range!(pages, format)
62
62
  return if pages.nil?
63
+ return pages if pages.empty?
63
64
 
64
65
  dash = translate('page-range-delimiter') || '–' # en-dash
65
66
 
@@ -1,5 +1,5 @@
1
1
  module CiteProc
2
2
  module Ruby
3
- VERSION = '1.1.7'
3
+ VERSION = '1.1.13'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,49 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citeproc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: citeproc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.4
20
- - - "<"
19
+ version: '1.0'
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '2.0'
22
+ version: 1.0.9
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.4
30
- - - "<"
29
+ version: '1.0'
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '2.0'
32
+ version: 1.0.9
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: csl
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.4'
39
+ version: '1.5'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.4'
46
+ version: '1.5'
47
47
  description: |
48
48
  CiteProc-Ruby is a Citation Style Language (CSL) 1.0.1 compatible cite
49
49
  processor implementation written in pure Ruby.
@@ -55,33 +55,19 @@ extra_rdoc_files: []
55
55
  files:
56
56
  - ".codeclimate.yml"
57
57
  - ".document"
58
- - ".rspec"
59
- - ".rubocop.yml"
60
- - ".simplecov"
61
58
  - ".yardopts"
62
59
  - AGPL
63
60
  - BSDL
64
61
  - Gemfile
65
- - Guardfile
66
62
  - README.md
67
63
  - Rakefile
68
64
  - cucumber.yml
69
- - features/bibliography.feature
70
- - features/locale_overrides.feature
71
- - features/name_options.feature
72
- - features/names.feature
73
- - features/renderer.feature
74
- - features/sort.feature
75
- - features/step_definitions/engine.rb
76
- - features/step_definitions/renderer.rb
77
- - features/style_immanent_locale_terms.feature
78
- - features/support/env.rb
79
- - features/support/hooks.rb
80
65
  - lib/citeproc/ruby.rb
81
66
  - lib/citeproc/ruby/engine.rb
82
67
  - lib/citeproc/ruby/format.rb
83
68
  - lib/citeproc/ruby/formats/default.rb
84
69
  - lib/citeproc/ruby/formats/html.rb
70
+ - lib/citeproc/ruby/formats/latex.rb
85
71
  - lib/citeproc/ruby/renderer.rb
86
72
  - lib/citeproc/ruby/renderer/choose.rb
87
73
  - lib/citeproc/ruby/renderer/date.rb
@@ -99,33 +85,11 @@ files:
99
85
  - lib/citeproc/ruby/renderer/text.rb
100
86
  - lib/citeproc/ruby/sort.rb
101
87
  - lib/citeproc/ruby/version.rb
102
- - spec/citeproc/ruby/engine_spec.rb
103
- - spec/citeproc/ruby/formats/default_spec.rb
104
- - spec/citeproc/ruby/formats/html_spec.rb
105
- - spec/citeproc/ruby/renderer/choose_spec.rb
106
- - spec/citeproc/ruby/renderer/date_spec.rb
107
- - spec/citeproc/ruby/renderer/group_spec.rb
108
- - spec/citeproc/ruby/renderer/history_spec.rb
109
- - spec/citeproc/ruby/renderer/label_spec.rb
110
- - spec/citeproc/ruby/renderer/layout_spec.rb
111
- - spec/citeproc/ruby/renderer/macro_spec.rb
112
- - spec/citeproc/ruby/renderer/names_spec.rb
113
- - spec/citeproc/ruby/renderer/number_spec.rb
114
- - spec/citeproc/ruby/renderer/text_spec.rb
115
- - spec/citeproc/ruby/renderer_spec.rb
116
- - spec/fixtures/items.rb
117
- - spec/fixtures/locales/locales-de-DE.xml
118
- - spec/fixtures/locales/locales-en-US.xml
119
- - spec/fixtures/locales/locales-fr-FR.xml
120
- - spec/fixtures/styles/apa-with-different-translations.csl
121
- - spec/fixtures/styles/apa.csl
122
- - spec/fixtures/styles/modern-language-association-8th-edition.csl
123
- - spec/spec_helper.rb
124
88
  homepage: https://github.com/inukshuk/citeproc-ruby
125
89
  licenses:
126
90
  - AGPL-3.0
127
91
  metadata: {}
128
- post_install_message:
92
+ post_install_message:
129
93
  rdoc_options: []
130
94
  require_paths:
131
95
  - lib
@@ -140,42 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
104
  - !ruby/object:Gem::Version
141
105
  version: '0'
142
106
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.6.12
145
- signing_key:
107
+ rubygems_version: 3.1.2
108
+ signing_key:
146
109
  specification_version: 4
147
110
  summary: A Citation Style Language (CSL) cite processor
148
- test_files:
149
- - features/bibliography.feature
150
- - features/locale_overrides.feature
151
- - features/name_options.feature
152
- - features/names.feature
153
- - features/renderer.feature
154
- - features/sort.feature
155
- - features/step_definitions/engine.rb
156
- - features/step_definitions/renderer.rb
157
- - features/style_immanent_locale_terms.feature
158
- - features/support/env.rb
159
- - features/support/hooks.rb
160
- - spec/citeproc/ruby/engine_spec.rb
161
- - spec/citeproc/ruby/formats/default_spec.rb
162
- - spec/citeproc/ruby/formats/html_spec.rb
163
- - spec/citeproc/ruby/renderer/choose_spec.rb
164
- - spec/citeproc/ruby/renderer/date_spec.rb
165
- - spec/citeproc/ruby/renderer/group_spec.rb
166
- - spec/citeproc/ruby/renderer/history_spec.rb
167
- - spec/citeproc/ruby/renderer/label_spec.rb
168
- - spec/citeproc/ruby/renderer/layout_spec.rb
169
- - spec/citeproc/ruby/renderer/macro_spec.rb
170
- - spec/citeproc/ruby/renderer/names_spec.rb
171
- - spec/citeproc/ruby/renderer/number_spec.rb
172
- - spec/citeproc/ruby/renderer/text_spec.rb
173
- - spec/citeproc/ruby/renderer_spec.rb
174
- - spec/fixtures/items.rb
175
- - spec/fixtures/locales/locales-de-DE.xml
176
- - spec/fixtures/locales/locales-en-US.xml
177
- - spec/fixtures/locales/locales-fr-FR.xml
178
- - spec/fixtures/styles/apa-with-different-translations.csl
179
- - spec/fixtures/styles/apa.csl
180
- - spec/fixtures/styles/modern-language-association-8th-edition.csl
181
- - spec/spec_helper.rb
111
+ test_files: []