asciidoctor-bibtex 0.3.1 → 0.4.0

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
- SHA1:
3
- metadata.gz: 1c520a15832ff368d7b14a6a8c7d65081dc5f91c
4
- data.tar.gz: 9433420aea00d9dfee97101f4fcab7efb87cf25e
2
+ SHA256:
3
+ metadata.gz: ef28bb04622b1fb0a08734642f086ecbafe496aad434374407cb8bbc4a88adcd
4
+ data.tar.gz: 80eaab008974ae4b2afbdf5f73229adaf11760954c5153471df5c78c39fb7b19
5
5
  SHA512:
6
- metadata.gz: d27c4efc1fb2ba1a73ef421070e3bfdc37556b73a529af48334f655c7c2c4f497488c0956b5927475424ccd6fa8849f511ba25b440e55b431b15d5f75a26a5de
7
- data.tar.gz: 3765a65c06eb84aa7eb60589beb33df412e4171ea3e322585efeaab8364d29e33689b3616eee969fd2c493516d82506a07d9626abdc9aac8af67985ea4e72048
6
+ metadata.gz: db5db5a418b582cf9df51a6b7fdf3bc45540e5514abfeb25a187576781442351bc1c9e71e50b977695bd0286a63c6522ca0014def475c1484f42d1840c6127e4
7
+ data.tar.gz: 86a4f7e498827c8ec94b5432d88d044307432df19d091ff58f209e2daa08d839c9a2108b5f074a73677a60942f2e0f7bbd0a71bb559b5abc09115a5c1dac134f
@@ -35,9 +35,7 @@ module AsciidoctorBibtex
35
35
  LaTeX::Decode::Punctuation.decode!(text)
36
36
  LaTeX::Decode::Symbols.decode!(text)
37
37
  LaTeX::Decode::Greek.decode!(text)
38
- text.gsub!(/\\url\{(.+?)\}/, " \\1 ")
39
- text.gsub!(/\\\w+(?=\s+\w)/, "")
40
- text.gsub!(/\\\w+(?:\[.+?\])?\s*\{(.+?)\}/, "\\1")
38
+ text = text.gsub(/\\url\{(.+?)\}/, " \\1 ").gsub(/\\\w+(?=\s+\w)/, "").gsub(/\\\w+(?:\[.+?\])?\s*\{(.+?)\}/, "\\1")
41
39
  LaTeX::Decode::Base.strip_braces(text)
42
40
  LaTeX.normalize_C(text)
43
41
  end
@@ -64,6 +62,9 @@ module AsciidoctorBibtex
64
62
  if attrs.key? :style and not parent.document.attr? 'bibtex-style'
65
63
  parent.document.set_attribute 'bibtex-style', attrs[:style]
66
64
  end
65
+ if attrs.key? :locale and not parent.document.attr? 'bibtex-locale'
66
+ parent.document.set_attribute 'bibtex-locale', attrs[:locale]
67
+ end
67
68
  create_paragraph parent, BibliographyBlockMacroPlaceholder, {}
68
69
  end
69
70
  end
@@ -77,6 +78,7 @@ module AsciidoctorBibtex
77
78
  def process document
78
79
  bibtex_file = (document.attr 'bibtex-file').to_s
79
80
  bibtex_style = ((document.attr 'bibtex-style') || 'ieee').to_s
81
+ bibtex_locale = ((document.attr 'bibtex-locale') || 'en-US').to_s
80
82
  bibtex_order = ((document.attr 'bibtex-order') || 'appearance').to_sym
81
83
  bibtex_format = ((document.attr 'bibtex-format') || 'asciidoc').to_sym
82
84
 
@@ -92,7 +94,7 @@ module AsciidoctorBibtex
92
94
  end
93
95
 
94
96
  bibtex = BibTeX.open bibtex_file, :filter => [LatexFilter]
95
- processor = Processor.new bibtex, true, bibtex_style, bibtex_order == :appearance, bibtex_format
97
+ processor = Processor.new bibtex, true, bibtex_style, bibtex_locale, bibtex_order == :appearance, bibtex_format
96
98
 
97
99
  prose_blocks = document.find_by {|b| b.content_model == :simple or b.context == :list_item}
98
100
  prose_blocks.each do |block|
@@ -110,13 +112,13 @@ module AsciidoctorBibtex
110
112
  if block.context == :list_item
111
113
  line = block.instance_variable_get :@text
112
114
  processor.citations.retrieve_citations(line).each do |citation|
113
- line.gsub!(citation.original, processor.complete_citation(citation))
115
+ line = line.gsub(citation.original, processor.complete_citation(citation))
114
116
  end
115
117
  block.instance_variable_set :@text, line
116
118
  else
117
119
  block.lines.each do |line|
118
120
  processor.citations.retrieve_citations(line).each do |citation|
119
- line.gsub!(citation.original, processor.complete_citation(citation))
121
+ line = line.gsub(citation.original, processor.complete_citation(citation))
120
122
  end
121
123
  end
122
124
  end
@@ -14,7 +14,7 @@ module AsciidoctorBibtex
14
14
  @pages = pages
15
15
  # clean up pages
16
16
  @pages = '' unless @pages
17
- @pages.gsub!("--","-")
17
+ @pages = @pages.gsub("--","-")
18
18
  end
19
19
 
20
20
  def to_s
@@ -13,18 +13,19 @@ module AsciidoctorBibtex
13
13
 
14
14
  attr_reader :biblio, :links, :style, :citations
15
15
 
16
- def initialize biblio, links, style, numeric_in_appearance_order = false, output = :asciidoc, bibfile = ""
16
+ def initialize biblio, links, style, locale, numeric_in_appearance_order = false, output = :asciidoc, bibfile = ""
17
17
  @biblio = biblio
18
18
  @links = links
19
19
  @numeric_in_appearance_order = numeric_in_appearance_order
20
20
  @style = style
21
+ @locale = locale
21
22
  @citations = Citations.new
22
23
  @filenames = Set.new
23
24
  @output = output
24
25
  @bibfile = bibfile
25
26
 
26
27
  if output != :latex and output != :bibtex and output != :biblatex
27
- @citeproc = CiteProc::Processor.new style: @style, format: :html
28
+ @citeproc = CiteProc::Processor.new style: @style, format: :html, locale: @locale
28
29
  @citeproc.import @biblio.to_citeproc
29
30
  end
30
31
  end
@@ -36,9 +37,16 @@ module AsciidoctorBibtex
36
37
  result = '+++'
37
38
  cite_data.cites.each do |cite|
38
39
  # NOTE: xelatex does not support "\citenp", so we output all
39
- # references as "cite" here.
40
- # result << "\\" << cite_data.type
41
- result << "\\" << 'cite'
40
+ # references as "cite" here unless we're using biblatex.
41
+ if @output == :biblatex
42
+ if cite_data.type == "citenp"
43
+ result << "\\" << 'textcite'
44
+ else
45
+ result << "\\" << 'parencite'
46
+ end
47
+ else
48
+ result << "\\" << 'cite'
49
+ end
42
50
  if cite.pages != ''
43
51
  result << "[p. " << cite.pages << "]"
44
52
  end
@@ -165,22 +173,19 @@ module AsciidoctorBibtex
165
173
  lc = ']'
166
174
  else
167
175
  cite_text = @citeproc.process id: ref, mode: :citation
168
-
169
- fc = cite_text[0,1]
170
- lc = cite_text[-1,1]
171
- cite_text = cite_text[1..-2]
176
+ fc = ''
177
+ lc = ''
172
178
  end
173
179
 
174
180
  if Styles.is_numeric? @style
175
181
  cite_text << "#{page_str(cite)}"
176
182
  elsif cite_data.type == "citenp"
177
- cite_text.gsub!(item.year, "#{fc}#{item.year}#{page_str(cite)}#{lc}")
178
- cite_text.gsub!(", #{fc}", " #{fc}")
183
+ cite_text = cite_text.gsub(item.year, "#{fc}#{item.year}#{page_str(cite)}#{lc}").gsub(", #{fc}", " #{fc}")
179
184
  else
180
185
  cite_text << page_str(cite)
181
186
  end
182
187
 
183
- cite_text.gsub!(",", "&#44;") if @links # replace comma
188
+ cite_text = cite_text.gsub(",", "&#44;") if @links # replace comma
184
189
 
185
190
  return cite_text, fc, lc
186
191
  end
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibtex
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-bibtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhang YANG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-26 00:00:00.000000000 Z
11
+ date: 2019-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: asciidoctor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.5.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: bibtex-ruby
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -112,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
132
  - !ruby/object:Gem::Version
113
133
  version: '0'
114
134
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.6.7
135
+ rubygems_version: 3.0.3
117
136
  signing_key:
118
137
  specification_version: 4
119
138
  summary: Adding bibtex functionality to asciidoc