asciidoctor-bibliography 0.9.1 → 0.9.2
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 +4 -4
- data/README.adoc +1 -0
- data/lib/asciidoctor-bibliography/citation.rb +4 -10
- data/lib/asciidoctor-bibliography/version.rb +1 -1
- data/spec/csl/styles/tex_citet_numeric_spec.rb +7 -7
- data/spec/csl/styles/tex_citets_numeric_spec.rb +7 -7
- data/spec/macros_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba310499dfc5790d5e46801371c1c061471695851dae7d30a33ca13d007fc1a5
|
4
|
+
data.tar.gz: 35133fcdbb5d12518dd71eac4a9fe57093620b098bdfe1579897cfb87521b62a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e61cd53c537606051c6ecd3e6ca2bb9c827647befd0368674358b203f4ede939ebb1cc21ba8b7b6fadf2265cd8b83b484241e2e489e7fc5ad0e990d6a6a06154
|
7
|
+
data.tar.gz: 77d251ea74096dc841b0f3663315b5dd4553a4e5b44ed329f6301def28a66f48c3d6a28250ecd92b1a745d0f1c8df6c13eaf1130685bc158e097c2921e21cdc7
|
data/README.adoc
CHANGED
@@ -150,6 +150,7 @@ cite:[Aa2017]+[Bb2017]+[Cc2017]
|
|
150
150
|
|
151
151
|
You can apply a different locator to each one.
|
152
152
|
|
153
|
+
IMPORTANT: when using a `prefix`, `suffix` or `text` containing `]` (the right square bracket character) remember to escape it as the corresponding HTML sequence `]`. E.g.: `cite:[Foo2019, text="see {cite} or [this] perhaps"]`.
|
153
154
|
|
154
155
|
=== Bibliographies
|
155
156
|
|
@@ -111,24 +111,18 @@ module AsciidoctorBibliography
|
|
111
111
|
formatter = Formatter.new(style, locale: bibliographer.options.locale)
|
112
112
|
items = prepare_items bibliographer, formatter, tex: tex
|
113
113
|
formatted_citation = formatter.engine.renderer.render(items, formatter.engine.style.citation)
|
114
|
-
escape_brackets_inside_xref! formatted_citation
|
115
114
|
interpolate_formatted_citation! formatted_citation
|
116
115
|
formatted_citation
|
117
116
|
end
|
118
117
|
|
119
|
-
def escape_brackets_inside_xref!(string)
|
120
|
-
string.gsub!(/{{{(?<xref_label>.*?)}}}/) do
|
121
|
-
["[", Regexp.last_match[:xref_label].gsub("]", '\]'), "]"].join
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
118
|
def interpolate_formatted_citation!(formatted_citation)
|
126
119
|
citation_items.each do |citation_item|
|
127
120
|
key = Regexp.escape citation_item.key
|
128
121
|
formatted_citation.gsub!(/___#{key}___(?<citation>.*?)___\/#{key}___/) do
|
129
|
-
# NOTE: this
|
122
|
+
# NOTE: this handles custom citation text (slight overkill but easy to extend)
|
123
|
+
# NOTE: escaping ] is necessary to safely nest macros (e.g. citing in a footnote)
|
130
124
|
(citation_item.text || "{cite}").
|
131
|
-
sub("{cite}", Regexp.last_match[:citation])
|
125
|
+
sub("{cite}", Regexp.last_match[:citation].gsub("]", "]"))
|
132
126
|
end
|
133
127
|
end
|
134
128
|
end
|
@@ -158,7 +152,7 @@ module AsciidoctorBibliography
|
|
158
152
|
wrap_item item, ci.prefix, ci.suffix if affix
|
159
153
|
id = xref_id "bibliography", ci.target, item.id
|
160
154
|
wrap_item item, "___#{item.id}___", "___/#{item.id}___"
|
161
|
-
wrap_item item, "
|
155
|
+
wrap_item item, "<<#{id},", ">>" if options.hyperlinks?
|
162
156
|
item.label, item.locator = ci.locator
|
163
157
|
end
|
164
158
|
|
@@ -7,36 +7,36 @@ describe "citet macro with numeric style" do
|
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citet:[Erdos65]", options: options)).
|
10
|
-
to eq "Erdős et al. [1
|
10
|
+
to eq "Erdős et al. [1]"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "formats a grouped citation" do
|
14
14
|
expect(formatted_citation("citet:[Erdos65]+[Einstein35]", options: options)).
|
15
|
-
to eq "Erdős et al. [1
|
15
|
+
to eq "Erdős et al. [1], Einstein et al. [2]"
|
16
16
|
end
|
17
17
|
|
18
18
|
it "formats a single citation with a prefix" do
|
19
19
|
expect(formatted_citation("citet:[Erdos65, prefix=see]", options: options)).
|
20
|
-
to eq "Erdős et al. [see 1
|
20
|
+
to eq "Erdős et al. [see 1]"
|
21
21
|
end
|
22
22
|
|
23
23
|
it "formats a single citation with a suffix" do
|
24
24
|
expect(formatted_citation("citet:[Erdos65, suffix=new edition]", options: options)).
|
25
|
-
to eq "Erdős et al. [1, new edition
|
25
|
+
to eq "Erdős et al. [1, new edition]"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "formats a single citation with both a prefix and a suffix" do
|
29
29
|
expect(formatted_citation("citet:[Erdos65, prefix=see, suffix=new edition]", options: options)).
|
30
|
-
to eq "Erdős et al. [see 1, new edition
|
30
|
+
to eq "Erdős et al. [see 1, new edition]"
|
31
31
|
end
|
32
32
|
|
33
33
|
it "formats a single citation with a standard locator" do
|
34
34
|
expect(formatted_citation("citet:[Erdos65, page=41-43]", options: options)).
|
35
|
-
to eq "Erdős et al. [1, pp. 41-43
|
35
|
+
to eq "Erdős et al. [1, pp. 41-43]"
|
36
36
|
end
|
37
37
|
|
38
38
|
it "formats a single citation with a custom locator" do
|
39
39
|
expect(formatted_citation("citet:[Erdos65, locator=somewhere]", options: options)).
|
40
|
-
to eq "Erdős et al. [1, somewhere
|
40
|
+
to eq "Erdős et al. [1, somewhere]"
|
41
41
|
end
|
42
42
|
end
|
@@ -7,36 +7,36 @@ describe "citet* macro with numeric style" do
|
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citet*:[Erdos65]", options: options)).
|
10
|
-
to eq "Erdős, Heyting, and Brouwer [1
|
10
|
+
to eq "Erdős, Heyting, and Brouwer [1]"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "formats a grouped citation" do
|
14
14
|
expect(formatted_citation("citet*:[Erdos65]+[Einstein35]", options: options)).
|
15
|
-
to eq "Erdős, Heyting, and Brouwer [1
|
15
|
+
to eq "Erdős, Heyting, and Brouwer [1], Einstein, Podolsky, and Rosen [2]"
|
16
16
|
end
|
17
17
|
|
18
18
|
it "formats a single citation with a prefix" do
|
19
19
|
expect(formatted_citation("citet*:[Erdos65, prefix=see]", options: options)).
|
20
|
-
to eq "Erdős, Heyting, and Brouwer [see 1
|
20
|
+
to eq "Erdős, Heyting, and Brouwer [see 1]"
|
21
21
|
end
|
22
22
|
|
23
23
|
it "formats a single citation with a suffix" do
|
24
24
|
expect(formatted_citation("citet*:[Erdos65, suffix=new edition]", options: options)).
|
25
|
-
to eq "Erdős, Heyting, and Brouwer [1, new edition
|
25
|
+
to eq "Erdős, Heyting, and Brouwer [1, new edition]"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "formats a single citation with both a prefix and a suffix" do
|
29
29
|
expect(formatted_citation("citet*:[Erdos65, prefix=see, suffix=new edition]", options: options)).
|
30
|
-
to eq "Erdős, Heyting, and Brouwer [see 1, new edition
|
30
|
+
to eq "Erdős, Heyting, and Brouwer [see 1, new edition]"
|
31
31
|
end
|
32
32
|
|
33
33
|
it "formats a single citation with a standard locator" do
|
34
34
|
expect(formatted_citation("citet*:[Erdos65, page=41-43]", options: options)).
|
35
|
-
to eq "Erdős, Heyting, and Brouwer [1, pp. 41-43
|
35
|
+
to eq "Erdős, Heyting, and Brouwer [1, pp. 41-43]"
|
36
36
|
end
|
37
37
|
|
38
38
|
it "formats a single citation with a custom locator" do
|
39
39
|
expect(formatted_citation("citet*:[Erdos65, locator=somewhere]", options: options)).
|
40
|
-
to eq "Erdős, Heyting, and Brouwer [1, somewhere
|
40
|
+
to eq "Erdős, Heyting, and Brouwer [1, somewhere]"
|
41
41
|
end
|
42
42
|
end
|
data/spec/macros_spec.rb
CHANGED
@@ -8,8 +8,8 @@ describe "cite macro with apa style" do
|
|
8
8
|
options: { "bibliography-style" => "apa",
|
9
9
|
"bibliography-database" => "database.bib",
|
10
10
|
"bibliography-hyperlinks" => "true" })).
|
11
|
-
to eq "(
|
12
|
-
"
|
11
|
+
to eq "(<<bibliography-default-Einstein35,Einstein, Podolsky, & Rosen, 1935, pp. 41-43>>; " +
|
12
|
+
"<<bibliography-default-Erdos65,seeErdős, Heyting, & Brouwer, 1965>>)"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -19,7 +19,7 @@ describe "cite macro with arbitrary interpolated text" do
|
|
19
19
|
options: { "bibliography-style" => "apa",
|
20
20
|
"bibliography-database" => "database.bib",
|
21
21
|
"bibliography-hyperlinks" => "true" })).
|
22
|
-
to eq "(
|
22
|
+
to eq "(<<bibliography-default-Erdos65,foo Erdős, Heyting, & Brouwer, 1965 bar>>)"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -48,6 +48,6 @@ describe "cite macro using more than two keys" do
|
|
48
48
|
options: { "bibliography-style" => "apa",
|
49
49
|
"bibliography-database" => "database.bib",
|
50
50
|
"bibliography-hyperlinks" => "true" })).
|
51
|
-
to eq "(
|
51
|
+
to eq "(<<bibliography-default-Einstein35,Einstein, Podolsky, & Rosen, 1935>>; <<bibliography-default-Erdos65,Erdős, Heyting, & Brouwer, 1965>>; <<bibliography-default-Lane12a,Lane, 2000>>; <<bibliography-default-Lane12b,Mane & Smith, 2000>>)"
|
52
52
|
end
|
53
53
|
end
|