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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04e18a2d4db4a21ae17510b7b76f756af63b3c8b
|
4
|
+
data.tar.gz: 82a982f607c46a9e1cb660fab823b0f1d099d014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c2d22e9338e4e8da8aa18e9c9d2e4f519ce703a7a2670decac5f1eb4e830d47ce17fbcb88da73623afb4deab47c0b5334fded92c1fb14f74a0a12c69e9f8260
|
7
|
+
data.tar.gz: 187be32bc3a2b14879185e9854bb7ef7f490820f9f7ef4a93387aa4428a80f02f4f0350a74f6298f8e6bcac0066d436c9ccb71baa40c10631f91af37455f6fdf
|
@@ -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
|
data/spec/citation_helper.rb
CHANGED
@@ -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(
|
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
|
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.
|
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-
|
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
|