asciidoctor-bibliography 0.4.0 → 0.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec220969b63ad6811daffac07fbf41eaec5a382d
4
- data.tar.gz: '089f60f0d33c8737b6308b7ab7a494dae7b93803'
3
+ metadata.gz: 04e18a2d4db4a21ae17510b7b76f756af63b3c8b
4
+ data.tar.gz: 82a982f607c46a9e1cb660fab823b0f1d099d014
5
5
  SHA512:
6
- metadata.gz: 8697d604dd13e6aa72fb652b6e8c61a1bbeef82ab4240d2de96fc0e15d02343646e9494e119baad65269a3802c5b32078e8c233aad864cb707d9943173704d0d
7
- data.tar.gz: 69704a0dc0dbd0a99142adc00752b904ad5a082baadd755f03b8e49a3b4871e49fdd7fc14bf88011f6eb6e723909791f9b1c986fff1b00e4a5800bb39fcf5964
6
+ metadata.gz: 3c2d22e9338e4e8da8aa18e9c9d2e4f519ce703a7a2670decac5f1eb4e830d47ce17fbcb88da73623afb4deab47c0b5334fded92c1fb14f74a0a12c69e9f8260
7
+ data.tar.gz: 187be32bc3a2b14879185e9854bb7ef7f490820f9f7ef4a93387aa4428a80f02f4f0350a74f6298f8e6bcac0066d436c9ccb71baa40c10631f91af37455f6fdf
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibliography
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.4.1".freeze
3
3
  end
@@ -4,10 +4,6 @@ module CiteProc
4
4
  module Ruby
5
5
  module Formats
6
6
  class Adoc < Format
7
- # TODO
8
- # def bibliography(bibliography)
9
- # end
10
-
11
7
  def apply_font_style
12
8
  output.replace "_#{output}_" if options[:'font-style'] == "italic"
13
9
  end
@@ -30,6 +26,18 @@ module CiteProc
30
26
  output.replace "^#{output}^" if options[:vertical_align] == "sup"
31
27
  output.replace "~#{output}~" if options[:vertical_align] == "sub"
32
28
  end
29
+
30
+ def apply_suffix
31
+ options[:suffix] += " " if aligned_first_field?
32
+ super
33
+ end
34
+
35
+ private
36
+
37
+ def aligned_first_field?
38
+ return false unless node.root.bibliography["second-field-align"]
39
+ node.root.bibliography.layout.children.first == node
40
+ end
33
41
  end
34
42
  end
35
43
  end
@@ -23,20 +23,21 @@ TEST_BIBTEX_DATABASE = <<~BIBTEX.freeze
23
23
  }
24
24
  BIBTEX
25
25
 
26
- def init_bibliographer(options)
26
+ def init_bibliographer(bibtex_db:, options: {})
27
27
  bibliographer = AsciidoctorBibliography::Bibliographer.new
28
28
 
29
29
  bibliographer.options = AsciidoctorBibliography::Options.new.
30
30
  merge("bibliography-hyperlinks" => "false").merge(options)
31
31
 
32
32
  bibliographer.database = AsciidoctorBibliography::Database.new.
33
- concat(::BibTeX.parse(TEST_BIBTEX_DATABASE).to_citeproc)
33
+ concat(::BibTeX.parse(bibtex_db).to_citeproc)
34
34
 
35
35
  bibliographer
36
36
  end
37
37
 
38
38
  def formatted_citation(macro, options: {})
39
- bibliographer = init_bibliographer options
39
+ bibliographer = init_bibliographer bibtex_db: TEST_BIBTEX_DATABASE,
40
+ options: options
40
41
 
41
42
  macro.gsub(AsciidoctorBibliography::Citation::REGEXP) do
42
43
  citation = AsciidoctorBibliography::Citation.new(*Regexp.last_match.captures)
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+
3
+ require "asciidoctor-bibliography"
4
+ require_relative "../../../citation_helper"
5
+
6
+ TEST_ADOC_SPEC_DATABASE = <<~BIBTEX.freeze
7
+ @article{Gettier63,
8
+ title={Is justified true belief knowledge?},
9
+ author={Gettier, Edmund L},
10
+ journal={analysis},
11
+ volume={23},
12
+ number={6},
13
+ pages={121--123},
14
+ year={1963},
15
+ publisher={JSTOR}
16
+ }
17
+ BIBTEX
18
+
19
+ def formatted_bibliography(macro, options: {})
20
+ bibliographer = init_bibliographer bibtex_db: TEST_ADOC_SPEC_DATABASE,
21
+ options: options
22
+
23
+ bibliographer.
24
+ add_citation AsciidoctorBibliography::Citation.new("cite", "", "Gettier63")
25
+
26
+ entries = macro.lines.map do |line|
27
+ return line unless line =~ AsciidoctorBibliography::Index::REGEXP
28
+ index = AsciidoctorBibliography::Index.new(*Regexp.last_match.captures)
29
+ index.render bibliographer
30
+ end
31
+
32
+ entries.flatten.map! { |ref| ref.gsub(/^{empty}anchor:.*?\[\]/, "") }
33
+ end
34
+
35
+ describe "custom :adoc citeproc format" do
36
+ let(:options) { { "bibliography-style" => "ieee" } }
37
+
38
+ it "adds space between first and second field" do
39
+ expect(formatted_bibliography("bibliography::[]", options: options).first).
40
+ to eq "[1] E. L. Gettier, “Is justified true belief knowledge?,” _analysis_, vol. 23, no. 6, pp. 121–123, 1963."
41
+ end
42
+ 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.4.0
4
+ version: 0.4.1
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-09-24 00:00:00.000000000 Z
11
+ date: 2017-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -266,6 +266,7 @@ files:
266
266
  - samples/tex/sample-sort.adoc
267
267
  - spec/citation_helper.rb
268
268
  - spec/citation_item_spec.rb
269
+ - spec/citeproc/ruby/formats/adoc_spec.rb
269
270
  - spec/csl/styles/tex_citealp_authoryear_spec.rb
270
271
  - spec/csl/styles/tex_citealp_numeric_spec.rb
271
272
  - spec/csl/styles/tex_citealps_authoryear_spec.rb