asciidoctor-bibliography 0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +17 -0
  4. data/Gemfile +1 -1
  5. data/Rakefile +3 -3
  6. data/asciidoctor-bibliography.gemspec +28 -26
  7. data/lib/asciidoctor-bibliography.rb +4 -1
  8. data/lib/asciidoctor-bibliography/asciidoctor.rb +3 -9
  9. data/lib/asciidoctor-bibliography/asciidoctor/bibliographer_preprocessor.rb +43 -15
  10. data/lib/asciidoctor-bibliography/asciidoctor/document_ext.rb +11 -0
  11. data/lib/asciidoctor-bibliography/bibliographer.rb +20 -9
  12. data/lib/asciidoctor-bibliography/citation.rb +74 -51
  13. data/lib/asciidoctor-bibliography/citation_item.rb +27 -0
  14. data/lib/asciidoctor-bibliography/database.rb +14 -7
  15. data/lib/asciidoctor-bibliography/databases/bibtex.rb +5 -4
  16. data/lib/asciidoctor-bibliography/exceptions.rb +5 -0
  17. data/lib/asciidoctor-bibliography/formatters/csl.rb +5 -0
  18. data/lib/asciidoctor-bibliography/formatters/tex.rb +20 -22
  19. data/lib/asciidoctor-bibliography/helpers.rb +3 -3
  20. data/lib/asciidoctor-bibliography/index.rb +21 -25
  21. data/lib/asciidoctor-bibliography/version.rb +1 -1
  22. data/samples/{biblio.bib → standard/biblio.bib} +0 -0
  23. data/samples/standard/sample-default.adoc +22 -0
  24. data/samples/standard/sample-default.html +476 -0
  25. data/samples/standard/sample-din.adoc +22 -0
  26. data/samples/standard/sample-din.html +476 -0
  27. data/samples/standard/sample-ieee.adoc +22 -0
  28. data/samples/standard/sample-ieee.html +476 -0
  29. data/samples/tex/biblio.bib +31 -0
  30. data/samples/{sample-authoryear.adoc → tex/sample-authoryear.adoc} +2 -3
  31. data/samples/{sample-authoryear.html → tex/sample-authoryear.html} +9 -6
  32. data/samples/tex/sample-din.adoc +74 -0
  33. data/samples/tex/sample-din.html +556 -0
  34. data/samples/{sample-numbers.adoc → tex/sample-numbers.adoc} +4 -0
  35. data/samples/{sample-numbers.html → tex/sample-numbers.html} +14 -8
  36. data/samples/tex/sample-ordering.adoc +20 -0
  37. data/samples/tex/sample-ordering.html +467 -0
  38. data/spec/citation_item_spec.rb +52 -0
  39. data/spec/database_spec.rb +39 -0
  40. data/spec/fixtures/database.bib +31 -0
  41. data/spec/fixtures/database.bibtex +6 -0
  42. data/spec/fixtures/database.unk +0 -0
  43. data/spec/throwaway_spec.rb +6 -0
  44. metadata +61 -25
  45. data/deprecated/asciidoctor-bibliography/asciidoctor/bibliographer_postprocessor.rb +0 -23
  46. data/deprecated/asciidoctor-bibliography/asciidoctor/bibliography_block_macro.rb +0 -77
  47. data/deprecated/asciidoctor-bibliography/asciidoctor/citation_processor.rb +0 -144
  48. data/deprecated/asciidoctor-bibliography/asciidoctor/cite_inline_macro.rb +0 -30
  49. data/deprecated/asciidoctor-bibliography/citationdata.rb +0 -23
  50. data/deprecated/asciidoctor-bibliography/citations.rb +0 -45
  51. data/deprecated/asciidoctor-bibliography/citationutils.rb +0 -67
  52. data/deprecated/asciidoctor-bibliography/extensions.rb +0 -64
  53. data/deprecated/asciidoctor-bibliography/filehandlers.rb +0 -32
  54. data/deprecated/asciidoctor-bibliography/index.rb +0 -31
  55. data/deprecated/asciidoctor-bibliography/processor.rb +0 -208
  56. data/deprecated/asciidoctor-bibliography/processorutils.rb +0 -34
  57. data/deprecated/asciidoctor-bibliography/styles.rb +0 -27
@@ -0,0 +1,52 @@
1
+ require 'asciidoctor-bibliography/helpers'
2
+
3
+ describe AsciidoctorBibliography::CitationItem do
4
+ describe '.new' do
5
+ it 'can be mutely initialized' do
6
+ expect { described_class.new }.to_not raise_exception
7
+ end
8
+
9
+ it 'can be initialized with a block operating on itself' do
10
+ itself = nil
11
+ expect(described_class.new { |ci| itself = ci }).to be(itself)
12
+ end
13
+ end
14
+
15
+ describe '#parse_attribute_list' do
16
+ subject { described_class.new }
17
+
18
+ before do
19
+ subject.parse_attribute_list 'foo, lol=bar, baz, qux, zod=13'
20
+ end
21
+
22
+ it 'treats the first positional attribute as the id' do
23
+ expect(subject.key).to eq 'foo'
24
+ end
25
+
26
+ it 'extracts the positional attributes in order, except the first one' do
27
+ expect(subject.positional_attributes).to eq ['baz', 'qux']
28
+ end
29
+
30
+ it 'extracts all named attributes' do
31
+ expect(subject.named_attributes).to eq({'lol' => 'bar', 'zod' => '13'})
32
+ end
33
+ end
34
+
35
+ describe '#locators' do
36
+ subject { described_class.new }
37
+
38
+ it 'returns no locators if none are present' do
39
+ subject.parse_attribute_list 'foo, lol=bar, baz, qux, zod=13'
40
+ expect(subject.locators).to eq ({})
41
+ end
42
+
43
+ it 'recognizes all CSL locators' do
44
+ locators = %w[book chapter column figure folio issue line note opus page paragraph part section sub-verbo verse volume]
45
+ locators_hash = locators.map { |l| [l, rand(10).to_s] }.to_h
46
+ locators_string = locators_hash.to_a.map { |a| a.join '=' }.join(', ')
47
+
48
+ subject.parse_attribute_list "foo, #{locators_string}"
49
+ expect(subject.locators).to eq locators_hash
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,39 @@
1
+ require 'asciidoctor-bibliography/helpers'
2
+
3
+ describe AsciidoctorBibliography::Database do
4
+ describe '.new' do
5
+ it 'is by default an empty array' do
6
+ expect(described_class.new).to eq([])
7
+ end
8
+
9
+ it 'can be initialized with a single database' do
10
+ expect(described_class.new("spec/fixtures/database.bib")).to_not eq([])
11
+ end
12
+
13
+ it 'can be initialized with a list of databases' do
14
+ expect(described_class.new("spec/fixtures/database.bib", "spec/fixtures/database.bibtex")).to_not eq([])
15
+ end
16
+ end
17
+
18
+ describe '#append' do
19
+ let(:db) { described_class.new }
20
+
21
+ it 'can load and concatenate databases after initialization' do
22
+ expect(db.length).to eq(0)
23
+ expect { db.append("spec/fixtures/database.bib") }.to change { db.length }
24
+ expect { db.append("spec/fixtures/database.bibtex") }.to change { db.length }
25
+ end
26
+ end
27
+
28
+ describe '.load' do
29
+ it 'raises error if given unknown format' do
30
+ expect { described_class.load 'spec/fixtures/database.unk' }
31
+ .to raise_exception AsciidoctorBibliography::Exceptions::DatabaseFormatNotSupported
32
+ end
33
+
34
+ it 'recognizes Bib(La)Tex databases' do
35
+ expect { described_class.load 'spec/fixtures/database.bib' }.to_not raise_exception
36
+ expect { described_class.load 'spec/fixtures/database.bibtex' }.to_not raise_exception
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,31 @@
1
+ @book{Lane12a,
2
+ author = {P. Lane},
3
+ title = {Book title},
4
+ publisher = {Publisher},
5
+ year = {2000}
6
+ }
7
+
8
+ @book{Lane12b,
9
+ author = {K. Mane and D. Smith},
10
+ title = {Book title},
11
+ publisher = {Publisher},
12
+ year = {2000}
13
+ }
14
+
15
+ @book{Anderson98,
16
+ editor = {J. R. Anderson and C. Lebiere},
17
+ title = {The Atomic Components of {2\sum} Thought},
18
+ publisher = {Lawrence Erlbaum},
19
+ address = {Mahwah, NJ},
20
+ year = {1998}
21
+ }
22
+
23
+ @article{Anderson04,
24
+ author = {J. R. Anderson and D. Bothell and M. D. Byrne and S. Douglass and C. Lebiere and Y. L. Qin},
25
+ title = {An integrated theory of the mind},
26
+ journal = {Psychological Review},
27
+ volume = {111},
28
+ number = {4},
29
+ pages = {1036--1060},
30
+ year = {2004}
31
+ }
@@ -0,0 +1,6 @@
1
+ @article{Bar10,
2
+ author = {F. Bar},
3
+ title = {Article title},
4
+ publisher = {Publisher},
5
+ year = {2010}
6
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ describe :throwaway do
2
+ # This just covers a couple of trivial lines to better track coverage.
3
+ # To be deleted when coverage is satisfactory.
4
+ document = Asciidoctor::Document.new
5
+ document.bibliographer
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-bibliography
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2017-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1.14'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '1.14'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: byebug
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,34 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  description: |
154
182
  asciidoctor-bibliography adds bibliography support for asciidoc documents by introducing
155
183
  two new macros: `cite:[KEY]` and `bibliography::[]`. Citations are parsed and
@@ -164,6 +192,7 @@ extra_rdoc_files: []
164
192
  files:
165
193
  - ".gitignore"
166
194
  - ".rspec"
195
+ - ".rubocop.yml"
167
196
  - ".travis.yml"
168
197
  - Gemfile
169
198
  - LICENSE.txt
@@ -171,40 +200,47 @@ files:
171
200
  - Rakefile
172
201
  - SYNTAX.adoc
173
202
  - asciidoctor-bibliography.gemspec
174
- - deprecated/asciidoctor-bibliography/asciidoctor/bibliographer_postprocessor.rb
175
- - deprecated/asciidoctor-bibliography/asciidoctor/bibliography_block_macro.rb
176
- - deprecated/asciidoctor-bibliography/asciidoctor/citation_processor.rb
177
- - deprecated/asciidoctor-bibliography/asciidoctor/cite_inline_macro.rb
178
- - deprecated/asciidoctor-bibliography/citationdata.rb
179
- - deprecated/asciidoctor-bibliography/citations.rb
180
- - deprecated/asciidoctor-bibliography/citationutils.rb
181
- - deprecated/asciidoctor-bibliography/extensions.rb
182
- - deprecated/asciidoctor-bibliography/filehandlers.rb
183
- - deprecated/asciidoctor-bibliography/index.rb
184
- - deprecated/asciidoctor-bibliography/processor.rb
185
- - deprecated/asciidoctor-bibliography/processorutils.rb
186
- - deprecated/asciidoctor-bibliography/styles.rb
187
203
  - lib/asciidoctor-bibliography.rb
188
204
  - lib/asciidoctor-bibliography/asciidoctor.rb
189
205
  - lib/asciidoctor-bibliography/asciidoctor/bibliographer_preprocessor.rb
206
+ - lib/asciidoctor-bibliography/asciidoctor/document_ext.rb
190
207
  - lib/asciidoctor-bibliography/bibliographer.rb
191
208
  - lib/asciidoctor-bibliography/citation.rb
209
+ - lib/asciidoctor-bibliography/citation_item.rb
192
210
  - lib/asciidoctor-bibliography/database.rb
193
211
  - lib/asciidoctor-bibliography/databases/bibtex.rb
212
+ - lib/asciidoctor-bibliography/exceptions.rb
194
213
  - lib/asciidoctor-bibliography/formatters/csl.rb
195
214
  - lib/asciidoctor-bibliography/formatters/tex.rb
196
215
  - lib/asciidoctor-bibliography/helpers.rb
197
216
  - lib/asciidoctor-bibliography/index.rb
198
217
  - lib/asciidoctor-bibliography/version.rb
199
- - samples/biblio.bib
200
218
  - samples/latex_macros_in_bibtex/reference.bib
201
219
  - samples/latex_macros_in_bibtex/sample.adoc
202
- - samples/sample-authoryear.adoc
203
- - samples/sample-authoryear.html
204
- - samples/sample-numbers.adoc
205
- - samples/sample-numbers.html
220
+ - samples/standard/biblio.bib
221
+ - samples/standard/sample-default.adoc
222
+ - samples/standard/sample-default.html
223
+ - samples/standard/sample-din.adoc
224
+ - samples/standard/sample-din.html
225
+ - samples/standard/sample-ieee.adoc
226
+ - samples/standard/sample-ieee.html
227
+ - samples/tex/biblio.bib
228
+ - samples/tex/sample-authoryear.adoc
229
+ - samples/tex/sample-authoryear.html
230
+ - samples/tex/sample-din.adoc
231
+ - samples/tex/sample-din.html
232
+ - samples/tex/sample-numbers.adoc
233
+ - samples/tex/sample-numbers.html
234
+ - samples/tex/sample-ordering.adoc
235
+ - samples/tex/sample-ordering.html
236
+ - spec/citation_item_spec.rb
237
+ - spec/database_spec.rb
238
+ - spec/fixtures/database.bib
239
+ - spec/fixtures/database.bibtex
240
+ - spec/fixtures/database.unk
206
241
  - spec/helpers_spec.rb
207
242
  - spec/spec_helper.rb
243
+ - spec/throwaway_spec.rb
208
244
  homepage: https://github.com/riboseinc/asciidoctor-bibliography
209
245
  licenses:
210
246
  - MIT
@@ -217,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
253
  requirements:
218
254
  - - ">="
219
255
  - !ruby/object:Gem::Version
220
- version: 2.0.0
256
+ version: 2.3.0
221
257
  required_rubygems_version: !ruby/object:Gem::Requirement
222
258
  requirements:
223
259
  - - ">="
@@ -1,23 +0,0 @@
1
- require 'asciidoctor'
2
- require 'asciidoctor/extensions'
3
-
4
- module AsciidoctorBibliography
5
- module Asciidoctor
6
-
7
- class BibliographerPostprocessor < ::Asciidoctor::Extensions::Postprocessor
8
- def process document, output
9
- puts self
10
- # byebug
11
- # content = (document.attr 'copyright') || 'Copyright Acme, Inc.'
12
- # if document.basebackend? 'html'
13
- # replacement = %(<div id="footer-text">\\1<br>\n#{content}\n</div>)
14
- # output = output.sub(/<div id="footer-text">(.*?)<\/div>/m, replacement)
15
- # elsif document.basebackend? 'docbook'
16
- # replacement = %(<simpara>#{content}</simpara>\n\\1)
17
- # output = output.sub(/(<\/(?:article|book)>)/, replacement)
18
- # end
19
- output
20
- end
21
- end
22
- end
23
- end
@@ -1,77 +0,0 @@
1
- require 'bibtex'
2
-
3
- require 'asciidoctor'
4
- require 'asciidoctor/extensions'
5
- require 'asciidoctor/reader'
6
- require 'asciidoctor/parser'
7
- # require 'bibliography/filters'
8
- # require 'latex/decode/base'
9
- # require 'latex/decode/maths'
10
- # require 'latex/decode/accents'
11
- # require 'latex/decode/diacritics'
12
- # require 'latex/decode/punctuation'
13
- # require 'latex/decode/symbols'
14
- # require 'latex/decode/greek'
15
- # require_relative 'styles'
16
- # require_relative 'filehandlers'
17
-
18
- require 'byebug'
19
-
20
- module AsciidoctorBibliography
21
- module Asciidoctor
22
- class BibliographyBlockMacro < ::Asciidoctor::Extensions::BlockMacroProcessor
23
- use_dsl
24
- named :bibliography
25
- # positional_attributes :style
26
-
27
- def process parent, target, attrs
28
- puts self
29
-
30
- # List of targets to render
31
- keys = parent.document.bibliographer.occurrences.map { |o| o[:target] }.uniq
32
-
33
-
34
- # NOTE: bibliography-file and bibliography-reference-style set by this macro
35
- # shall be overridable by document attributes and commandline arguments.
36
- # So we respect the convention here.
37
-
38
- # if target and not parent.document.attr? 'bibliography-file'
39
- # parent.document.set_attribute 'bibliography-file', target
40
- # end
41
-
42
- if parent.document.attr? 'bibliography-database'
43
- parent.document.bibliographer.load_database parent.document.attributes['bibliography-database']
44
- end
45
-
46
- # if attrs.key? :style and not parent.document.attr? 'bibliography-reference-style'
47
- # parent.document.set_attribute 'bibliography-reference-style', attrs[:style]
48
- # end
49
-
50
- # index = AsciidoctorBibliography::Index.new parent, target, attrs, SecureRandom.uuid
51
- # parent.document.bibliographer.indices << index
52
-
53
- # html = index.placeholder
54
- # attrs = {}
55
-
56
- # create_pass_block parent, html, attrs#, subs: nil
57
-
58
- # parent.document.register :links, target
59
- # create_anchor parent, text, type: :link, target: target
60
-
61
- # byebug
62
-
63
- # keys.each do |key|
64
- # create_paragraph parent, key, {}
65
- # end
66
-
67
- # index_block = create_block parent, a
68
- create_paragraph index_block, keys.first, {}
69
-
70
- # Asciidoctor::Block.new(parent, :paragraph, :source => '_This_ is a <test>')
71
-
72
- # TODO: unordered list
73
- end
74
- end
75
-
76
- end
77
- end
@@ -1,144 +0,0 @@
1
- require 'asciidoctor'
2
- require 'asciidoctor/extensions'
3
- require 'asciidoctor/reader'
4
- require 'asciidoctor/parser'
5
- # require 'bibtex/filters'
6
- # require 'latex/decode/base'
7
- # require 'latex/decode/maths'
8
- # require 'latex/decode/accents'
9
- # require 'latex/decode/diacritics'
10
- # require 'latex/decode/punctuation'
11
- # require 'latex/decode/symbols'
12
- # require 'latex/decode/greek'
13
- # require_relative 'styles'
14
- # require_relative 'filehandlers'
15
-
16
- module AsciidoctorBibliography
17
- module Asciidoctor
18
-
19
- # This filter extends the original latex filter in bibtex-ruby to handle
20
- # unknown latex macros more gracefully. We could have used latex-decode
21
- # gem together with our custom replacement rules, but latex-decode eats up
22
- # all braces after it finishes all decoding. So we hack over the
23
- # LaTeX.decode function and insert our rules before `strip_braces`.
24
- # class LatexFilter < ::BibTeX::Filter
25
- # def apply(value)
26
- # text = value.to_s
27
- # LaTeX::Decode::Base.normalize(text)
28
- # LaTeX::Decode::Maths.decode!(text)
29
- # LaTeX::Decode::Accents.decode!(text)
30
- # LaTeX::Decode::Diacritics.decode!(text)
31
- # LaTeX::Decode::Punctuation.decode!(text)
32
- # LaTeX::Decode::Symbols.decode!(text)
33
- # LaTeX::Decode::Greek.decode!(text)
34
- # text.gsub!(/\\url\{(.+?)\}/, " \\1 ")
35
- # text.gsub!(/\\\w+(?=\s+\w)/, "")
36
- # text.gsub!(/\\\w+(?:\[.+?\])?\s*\{(.+?)\}/, "\\1")
37
- # LaTeX::Decode::Base.strip_braces(text)
38
- # LaTeX.normalize_C(text)
39
- # end
40
- # end
41
-
42
- # This processor scans the document, generates a list of citations,
43
- # replace each citation with correct text and the reference block macro
44
- # placeholder with the final reference list. It relys on the block macro
45
- # processor to generate the place holder.
46
- class CitationProcessor < ::Asciidoctor::Extensions::Treeprocessor
47
-
48
- def process document
49
- puts self
50
- # byebug
51
- # bibtex_file = (document.attr 'bibtex-file').to_s
52
- # bibtex_style = ((document.attr 'bibtex-style') || 'ieee').to_s
53
- # bibtex_order = ((document.attr 'bibtex-order') || 'appearance').to_sym
54
- # bibtex_format = ((document.attr 'bibtex-format') || 'asciidoc').to_sym
55
-
56
- # if bibtex_file.empty?
57
- # bibtex_file = AsciidoctorBibliography::FileHandlers.find_bibliography "."
58
- # end
59
- # if bibtex_file.empty?
60
- # bibtex_file = AsciidoctorBibliography::FileHandlers.find_bibliography "#{ENV['HOME']}/Documents"
61
- # end
62
- # if bibtex_file.empty?
63
- # puts "Error: bibtex-file is not set and automatic search failed"
64
- # exit
65
- # end
66
-
67
- # bibtex = BibTeX.open bibtex_file, :filter => [LatexFilter]
68
- # processor = Processor.new bibtex, true, bibtex_style, bibtex_order == :appearance, bibtex_format
69
-
70
- # prose_blocks = document.find_by {|b| b.content_model == :simple or b.context == :list_item}
71
- # prose_blocks.each do |block|
72
- # if block.context == :list_item
73
- # line = block.instance_variable_get :@text
74
- # processor.citations.add_from_line line
75
- # else
76
- # block.lines.each do |line|
77
- # processor.citations.add_from_line line
78
- # end
79
- # end
80
- # end
81
-
82
- # prose_blocks.each do |block|
83
- # if block.context == :list_item
84
- # line = block.instance_variable_get :@text
85
- # processor.citations.retrieve_citations(line).each do |citation|
86
- # line.gsub!(citation.original, processor.complete_citation(citation))
87
- # end
88
- # block.instance_variable_set :@text, line
89
- # else
90
- # block.lines.each do |line|
91
- # processor.citations.retrieve_citations(line).each do |citation|
92
- # line.gsub!(citation.original, processor.complete_citation(citation))
93
- # end
94
- # end
95
- # end
96
- # end
97
-
98
- # references_asciidoc = []
99
- # if bibtex_format == :latex
100
- # references_asciidoc << %(+++\\bibliography{#{bibtex_file}}{}+++)
101
- # references_asciidoc << %(+++\\bibliographystyle{#{bibtex_style}}+++)
102
- # else
103
- # processor.cites.each do |ref|
104
- # references_asciidoc << processor.get_reference(ref)
105
- # references_asciidoc << ''
106
- # end
107
- # end
108
-
109
- # biblio_blocks = document.find_by do |b|
110
- # # for fast search (since most searches shall fail)
111
- # b.content_model == :simple and b.lines.size == 1 \
112
- # and b.lines[0] == BibliographyBlockMacroPlaceholder
113
- # end
114
- # biblio_blocks.each do |block|
115
- # block_index = block.parent.blocks.index do |b|
116
- # b == block
117
- # end
118
- # reference_blocks = parse_asciidoc block.parent, references_asciidoc
119
- # reference_blocks.reverse.each do |b|
120
- # block.parent.blocks.insert block_index, b
121
- # end
122
- # block.parent.blocks.delete_at block_index + reference_blocks.size
123
- # end
124
-
125
- # nil
126
- end
127
-
128
- # This is an adapted version of Asciidoctor::Extension::parse_content,
129
- # where resultant blocks are returned as a list instead of attached to
130
- # the parent.
131
- def parse_asciidoc parent, content, attributes = {}
132
- result = []
133
- reader = ::Asciidoctor::Reader.new content
134
- while reader.has_more_lines?
135
- block = ::Asciidoctor::Parser.next_block reader, parent, attributes
136
- result << block if block
137
- end
138
- result
139
- end
140
-
141
- end
142
-
143
- end
144
- end