asciidoctor-bibliography 0.7.0 → 0.7.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
  SHA1:
3
- metadata.gz: 6160a0148bcc81aa588bd2c333b4cb209ffc1ec7
4
- data.tar.gz: fff771f653fb8dd39bc581326748afe767c884c4
3
+ metadata.gz: 241505801324d38d708ac52fdf8c24755dd16ef5
4
+ data.tar.gz: 0a7ac064f2d07b664df8ad1405a00dc6613e5533
5
5
  SHA512:
6
- metadata.gz: 252da4287ea790422111c8628686675672c5dd8422daf89c721d118a94a935b221d1f1ceb3ce3ce140d57863ff13c0489ab6424cc3e22ba04b4ff14977d9e4ef
7
- data.tar.gz: 3be21ac1c4ed50b01f6cda42b898c2af9e0cead327bc17c854b32b8a6c342220a1d5736bffb084bbeb3abbc0ceee5599bf18aeb84e4e61b9062a3887bc7ad120
6
+ metadata.gz: c2f0719e9e1219b3d09073d430d498b142472dff3dda41543f8df80c6293ff65739c9c260ba95a92464d39c1d4a6ce5a140120009cdaef41fd15e422173a9855
7
+ data.tar.gz: e33ccc4676b4d5087e1ac4b38573ff3d1f7cad8b5a0ed799e5060ff968795989b965c4c9087ac4769aea48f6c77fce7ab856c15a92c652711f73e67a3d48f869
data/README.adoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = Citations and Bibliography the "asciidoctor-way"
2
2
 
3
3
  asciidoctor-bibliography lets you handle citations and bibliography the
4
- "http://asciidoctor.org/[asciidoctor]-way"!
4
+ http://asciidoctor.org/[asciidoctor]-way!
5
5
 
6
6
  image:https://img.shields.io/gem/v/asciidoctor-bibliography.svg["Gem Version", link="https://rubygems.org/gems/asciidoctor-bibliography"]
7
7
  image:https://img.shields.io/travis/riboseinc/asciidoctor-bibliography/master.svg["Build Status", link="https://travis-ci.org/riboseinc/asciidoctor-bibliography"]
@@ -193,7 +193,11 @@ Specifying a database file is mandatory and it can be done in the header with it
193
193
  :bibliography-database: my_database.bib
194
194
  ----
195
195
 
196
- Currently only the `BibTeX` format is supported; more will come soon.
196
+ Currently only the `BibTeX` format is supported, with `.bib` or `.bibtex` extensions.
197
+
198
+ `BibLaTeX` databases can be used too, but only the subset of features belonging to `BibTeX`
199
+ are safe to use: unknown attributes will be silently ignored. If the file has `.biblatex`
200
+ extension the you will receive a warning on compilation.
197
201
 
198
202
 
199
203
  === Styling
@@ -300,9 +304,11 @@ As for the `sort` option, the valid values are `ascending` (default) and `descen
300
304
 
301
305
  === TeX-mode
302
306
 
303
- While the `cite` macro is reserved for CSL styling, all traditional Bib(La)TeX macros are accessible through the same syntax with their usual names:
307
+ While the `cite` macro is reserved for CSL styling and works with thousands of styles,
308
+ the traditional Bib(La)TeX macros are also implemented with their usual names
309
+ and can be used with a few styles:
304
310
 
305
- * `citet`
311
+ * `citet` (in `LaTeX` world `\citet` is equivalent to `\cite`)
306
312
  * `citet*`
307
313
  * `citealt`
308
314
  * `citealt*`
@@ -315,8 +321,6 @@ While the `cite` macro is reserved for CSL styling, all traditional Bib(La)TeX m
315
321
  * `citeyear`
316
322
  * `citeyearpar`
317
323
 
318
- NOTE: no macros are missing since `\cite` is equivalent to `\citet`!
319
-
320
324
  To cite multiple items you can concatenate them just like with `cite`.
321
325
 
322
326
  All macros accept standard locators, `locator`, `suffix` and `prefix`.
@@ -332,7 +336,13 @@ You can set their style in the header:
332
336
 
333
337
  Accepted values are `authoryear` (default) and `numeric`.
334
338
 
335
- Furthermore, `fullcite` is also available and accepts no parameters except a single reference key.
339
+ IMPORTANT: The `cite` macro and the `cite...` macros described in this section are completely
340
+ independent mechanisms. The former is styled with `:bibliography-style:` (thousands of styles available)
341
+ while the latter is styled with with `:bibliography-tex-style:` (much more limited, only has the
342
+ styles listed above).
343
+
344
+ The macro `fullcite` is also available and accepts no parameters except a single reference key.
345
+ Unlike its siblings, it is able to render CSL styles and is configured using `:bibliography-style:`.
336
346
 
337
347
  ==== Advanced options
338
348
 
@@ -350,6 +360,17 @@ Sometimes it is desirable to wrap the rendered citations in a passthrough. Using
350
360
  :bibliography-passthrough: false
351
361
  ----
352
362
 
363
+ ==== CLI usage
364
+
365
+ All header attributes described above can also be passed through the commandline as is customary. E.g.:
366
+
367
+ [source,console]
368
+ ----
369
+ $ asciidoctor -r asciidoctor-bibliography -a bibliography-style=ieee my_first_document.adoc
370
+ ----
371
+
372
+ Values given in such way will take highest priority.
373
+
353
374
  == Development
354
375
 
355
376
  We follow Sandi Metz's Rules for this gem, you can read the
@@ -10,7 +10,7 @@ module AsciidoctorBibliography
10
10
  class BibliographerPreprocessor < ::Asciidoctor::Extensions::Preprocessor
11
11
  def process(document, reader)
12
12
  document.bibliographer.options =
13
- ::AsciidoctorBibliography::Options.new_from_reader reader
13
+ ::AsciidoctorBibliography::Options.build document, reader
14
14
 
15
15
  database_filepath =
16
16
  File.expand_path document.bibliographer.options.database,
@@ -11,9 +11,13 @@ require "latex/decode/greek"
11
11
  module AsciidoctorBibliography
12
12
  module Databases
13
13
  module BibTeX
14
- EXTENSIONS = %w[.bib .bibtex].freeze
14
+ EXTENSIONS = %w[.bib .bibtex .biblatex].freeze
15
15
 
16
16
  def self.load(filename)
17
+ # TODO: detect BibLaTeX code w/ other extensions
18
+ warn <<~MESSAGE if File.extname(filename) == '.biblatex'
19
+ WARNING: you are requiring a BibLaTeX database; only features compatible with BibTeX are guaranteed to work.
20
+ MESSAGE
17
21
  ::BibTeX.open(filename, filter: [LatexFilter]).to_citeproc
18
22
  end
19
23
 
@@ -22,10 +22,11 @@ module AsciidoctorBibliography
22
22
  merge DEFAULTS
23
23
  end
24
24
 
25
- def self.new_from_reader(reader)
25
+ def self.build(document, reader)
26
26
  header_attributes = get_header_attributes_hash reader
27
27
  header_attributes.select! { |key, _| DEFAULTS.keys.include? key }
28
- new.merge header_attributes
28
+ cli_attributes = document.attributes.select { |key, _| DEFAULTS.keys.include? key }
29
+ new.merge!(header_attributes).merge!(cli_attributes)
29
30
  end
30
31
 
31
32
  def self.get_header_attributes_hash(reader)
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibliography
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.7.2".freeze
3
3
  end
@@ -1,27 +1,20 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
3
3
  <info>
4
- <title>RFC v2 style</title>
5
- <id>rfc-v2</id>
6
- <updated>2017-11-04T15:15:55+00:00</updated>
4
+ <title>RFC v3 style</title>
5
+ <id>rfc-v3</id>
6
+ <updated>2017-11-04T16:30:44+00:00</updated>
7
7
  </info>
8
8
  <macro name="citation-locator">
9
9
  <group>
10
10
  <label variable="locator" text-case="capitalize-first"/>
11
- <text variable="locator" prefix=" "/>
12
11
  </group>
13
12
  </macro>
14
13
  <citation>
15
14
  <layout>
16
- <group>
17
- <group prefix="&lt;xref" suffix="&gt;">
18
- <text variable="citation-label" prefix=" target=&quot;" suffix="&quot;"/>
19
- </group>
20
- <group delimiter=", ">
21
- <text variable="citation-label" prefix="[" suffix="]"/>
22
- <text macro="citation-locator"/>
23
- </group>
24
- <text value="&lt;/xref&gt;"/>
15
+ <group delimiter=" " prefix="&lt;xref " suffix="/&gt;">
16
+ <text variable="citation-label" prefix="target=&quot;" suffix="&quot;"/>
17
+ <text variable="locator" prefix="section=&quot;" suffix="&quot;"/>
25
18
  </group>
26
19
  </layout>
27
20
  </citation>
@@ -7,12 +7,12 @@ describe "cite macro with rfc-v2 style" do
7
7
 
8
8
  it "formats a single citation" do
9
9
  expect(formatted_citation("cite:[RFC2119]", options: options)).
10
- to eq '+++<xref target="RFC2119">[RFC2119]</xref>+++'
10
+ to eq '+++<xref target="RFC2119"/>+++'
11
11
  end
12
12
 
13
13
  it "formats a single citation with locator" do
14
14
  expect(formatted_citation("cite:[RFC2119, section=1.2.3]", options: options)).
15
- to eq '+++<xref target="RFC2119">[RFC2119], Section 1.2.3</xref>+++'
15
+ to eq '+++<xref target="RFC2119" section="1.2.3"/>+++'
16
16
  end
17
17
 
18
18
  it "formats a single bibliography entry" do
data/spec/options_spec.rb CHANGED
@@ -160,9 +160,16 @@ describe AsciidoctorBibliography::Options do
160
160
  end
161
161
  end
162
162
 
163
- describe ".new_from_reader" do
163
+ describe ".build" do
164
+ let(:document) do
165
+ ::Asciidoctor::Document.new.tap do |doc|
166
+ # NOTE: these attributes would come from CLI
167
+ doc.attributes.merge! "bibliography-database" => "high_priority"
168
+ end
169
+ end
170
+
164
171
  let(:reader) do
165
- ::Asciidoctor::PreprocessorReader.new(::Asciidoctor::Document.new, <<~SOURCE.lines)
172
+ ::Asciidoctor::PreprocessorReader.new(document, <<~SOURCE.lines)
166
173
  = This is the document title
167
174
  :bibliography-database: foo
168
175
  :bibliography-locale: bar
@@ -175,10 +182,10 @@ describe AsciidoctorBibliography::Options do
175
182
  SOURCE
176
183
  end
177
184
 
178
- subject { described_class.new_from_reader reader }
185
+ subject { described_class.build document, reader }
179
186
 
180
- it "extracts all bibliography options ignoring others" do
181
- expect(subject).to eq("bibliography-database" => "foo",
187
+ it "extracts all bibliography options ignoring others and includes CLI attributes" do
188
+ expect(subject).to eq("bibliography-database" => "high_priority",
182
189
  "bibliography-locale" => "bar",
183
190
  "bibliography-style" => "baz",
184
191
  "bibliography-hyperlinks" => "quz",
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.7.0
4
+ version: 0.7.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: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -341,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
341
  version: '0'
342
342
  requirements: []
343
343
  rubyforge_project:
344
- rubygems_version: 2.5.2
344
+ rubygems_version: 2.6.14
345
345
  signing_key:
346
346
  specification_version: 4
347
347
  summary: Citations and bibliography the "asciidoctor-way"