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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5f4c3c1adb3bab1871b0aca0401e8b2400389952ac1aa6879982d37759e0309
4
- data.tar.gz: 4eb784aa9204c2bd4b34784511f1e549d3ab7f94e1079f27ff9898e3baa2a55a
3
+ metadata.gz: ba310499dfc5790d5e46801371c1c061471695851dae7d30a33ca13d007fc1a5
4
+ data.tar.gz: 35133fcdbb5d12518dd71eac4a9fe57093620b098bdfe1579897cfb87521b62a
5
5
  SHA512:
6
- metadata.gz: 905cd2e676a6a66d893163c8f9f01cc60f7a4798536a9976ec9bf1d8e130257f05adcbc7de155a74a2dbe9a074302180ceb2cfe80b2b0daa409ab8aeda32c910
7
- data.tar.gz: 2b45d610368bd5ac57f83a47d5d517756844f3b6387e06c9bd2a45feaca4d8e51bfad15296701281da3388c0fbb63dafcfc3608c2645779d80a769ed7b16b8fd
6
+ metadata.gz: e61cd53c537606051c6ecd3e6ca2bb9c827647befd0368674358b203f4ede939ebb1cc21ba8b7b6fadf2265cd8b83b484241e2e489e7fc5ad0e990d6a6a06154
7
+ data.tar.gz: 77d251ea74096dc841b0f3663315b5dd4553a4e5b44ed329f6301def28a66f48c3d6a28250ecd92b1a745d0f1c8df6c13eaf1130685bc158e097c2921e21cdc7
@@ -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 is slight overkill but easy to extend
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("]", "&rsqb;"))
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, "xref:#{id}{{{", "}}}" if options.hyperlinks?
155
+ wrap_item item, "<<#{id},", ">>" if options.hyperlinks?
162
156
  item.label, item.locator = ci.locator
163
157
  end
164
158
 
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibliography
2
- VERSION = "0.9.1".freeze
2
+ VERSION = "0.9.2".freeze
3
3
  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 et al. [1]"
10
+ to eq "Erdős et al. [1&rsqb;"
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], Einstein et al. [2]"
15
+ to eq "Erdős et al. [1&rsqb;, Einstein et al. [2&rsqb;"
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&rsqb;"
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&rsqb;"
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&rsqb;"
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&rsqb;"
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&rsqb;"
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&rsqb;"
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], Einstein, Podolsky, and Rosen [2]"
15
+ to eq "Erdős, Heyting, and Brouwer [1&rsqb;, Einstein, Podolsky, and Rosen [2&rsqb;"
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&rsqb;"
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&rsqb;"
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&rsqb;"
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&rsqb;"
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&rsqb;"
41
41
  end
42
42
  end
@@ -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 "(xref:bibliography-default-Einstein35[Einstein, Podolsky, & Rosen, 1935, pp. 41-43]; " +
12
- "xref:bibliography-default-Erdos65[seeErdős, Heyting, & Brouwer, 1965])"
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 "(xref:bibliography-default-Erdos65[foo Erdős, Heyting, & Brouwer, 1965 bar])"
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 "(xref:bibliography-default-Einstein35[Einstein, Podolsky, & Rosen, 1935]; xref:bibliography-default-Erdos65[Erdős, Heyting, & Brouwer, 1965]; xref:bibliography-default-Lane12a[Lane, 2000]; xref:bibliography-default-Lane12b[Mane & Smith, 2000])"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-bibliography
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.