asciidoctor-bibliography 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b44fba0dae7053aca56cd4e438f586de5b53e91559c13109499deaba80af8a4d
4
- data.tar.gz: d08a5ff76362ccab31e85e9bf5c49a820d17af670fdd4cfe0e73aa8d7e57a126
3
+ metadata.gz: d911a6644108601920bb73e4e1e9edcb5e01dfa83c6e1dc76f5677d10f465237
4
+ data.tar.gz: e58a22d8208586825a66d7edbcbc5d4ca9bbe2dc1fab592c9ffa23bdc27c5917
5
5
  SHA512:
6
- metadata.gz: f0a07e29c0ebc1388feb61328227e343e610cc6ec78c394c4538f47b115f818d0b4294408df1b5fb2a68334aae80fedb9e4bf4c09ab9e241e05a0d3321d98318
7
- data.tar.gz: 2628aef9ba841b076651698f04413bda11ba159e098e3348ee719d552ab09f2b4acad3fb358cb95d9f7fc758f326108fe8959ea3c191c49abc09794e77c335e8
6
+ metadata.gz: 93f938bfd5d6691ca9d41b3e75802fced6dbe90c5ad47f0228249b011df5bb7164b899a79296717df191a0c975f14a7ed2486be8c8e84288d6bb5ee1101b2f13
7
+ data.tar.gz: bbf0335799d70508d44702da8608d6134b8ab9414b59dd75775bc5685ddd0436690855bd17fc9adc75283b17f12094eb72dfc2c59e7efdf26eafe957cab463d5
@@ -124,7 +124,7 @@ module AsciidoctorBibliography
124
124
  # NOTE: this handles custom citation text (slight overkill but easy to extend)
125
125
  # NOTE: escaping ] is necessary to safely nest macros (e.g. citing in a footnote)
126
126
  (citation_item.text || "{cite}").
127
- sub("{cite}", Regexp.last_match[:citation].gsub("]", "]"))
127
+ sub("{cite}", escape_square_brackets(Regexp.last_match[:citation]))
128
128
  end
129
129
  end
130
130
  end
@@ -170,5 +170,11 @@ module AsciidoctorBibliography
170
170
  def xref_id(*fragments)
171
171
  fragments.compact.join("-")
172
172
  end
173
+
174
+ private
175
+
176
+ def escape_square_brackets(string)
177
+ string.gsub("[", "[").gsub("]", "]")
178
+ end
173
179
  end
174
180
  end
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibliography
2
- VERSION = "0.10.1".freeze
2
+ VERSION = "0.10.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]"
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], 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], Einstein, Podolsky, and Rosen [2]"
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
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+
3
+ require "asciidoctor-bibliography"
4
+
5
+ describe "rendering citations styles containing square brackets" do
6
+ let(:parsed_document) do
7
+ Asciidoctor::Document.new(<<~ADOC_INPUT).tap(&:parse)
8
+ = Sample document
9
+ :bibliography-database: spec/fixtures/database.bib
10
+ :bibliography-hyperlinks: true
11
+ :bibliography-style: ieee
12
+ ...
13
+
14
+ This paragraph contains a citation: cite:[Lane12a].
15
+ It also contains [.my-class]#some# inline styling.
16
+ ADOC_INPUT
17
+ end
18
+
19
+ it "does not confuse rendered brackets with macro brackets in the paragraph" do
20
+ # I.e. we're trying to avoid results like
21
+ # ```
22
+ # <p>This paragraph contains a citation: <a href="#bibliography-default-Lane12a"><span class="1&rsqb;</a>.
23
+ # It also contains [.my-class">some</span> inline styling.</p>
24
+ # ```
25
+ expect(parsed_document.render).to eq(<<~HTML_OUTPUT.strip)
26
+ <div class="paragraph">
27
+ <p>This paragraph contains a citation: <a href="#bibliography-default-Lane12a">&lsqb;1&rsqb;</a>.
28
+ It also contains <span class="my-class">some</span> inline styling.</p>
29
+ </div>
30
+ HTML_OUTPUT
31
+ end
32
+ 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.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-16 00:00:00.000000000 Z
11
+ date: 2019-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -307,6 +307,7 @@ files:
307
307
  - spec/fixtures/database.rfc.xml
308
308
  - spec/fixtures/database.unk
309
309
  - spec/index_spec.rb
310
+ - spec/integration_spec.rb
310
311
  - spec/macros_spec.rb
311
312
  - spec/nocite_spec.rb
312
313
  - spec/options_spec.rb
@@ -332,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
333
  - !ruby/object:Gem::Version
333
334
  version: '0'
334
335
  requirements: []
335
- rubygems_version: 3.0.3
336
+ rubygems_version: 3.0.4
336
337
  signing_key:
337
338
  specification_version: 4
338
339
  summary: Citations and bibliography the "asciidoctor-way"