asciidoctor-bibliography 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.oss-guides.rubocop.yml +0 -8
- data/.rubocop.yml +2 -0
- data/.travis.yml +1 -1
- data/README.adoc +16 -0
- data/asciidoctor-bibliography.gemspec +2 -0
- data/lib/asciidoctor-bibliography.rb +5 -0
- data/lib/asciidoctor-bibliography/citation.rb +26 -16
- data/lib/asciidoctor-bibliography/database.rb +3 -0
- data/lib/asciidoctor-bibliography/databases/rfc.rb +52 -0
- data/lib/asciidoctor-bibliography/index.rb +9 -4
- data/lib/asciidoctor-bibliography/options.rb +61 -28
- data/lib/asciidoctor-bibliography/version.rb +1 -1
- data/lib/csl/styles/rfc-v2.csl +33 -0
- data/lib/csl/styles/rfc-v3.csl +26 -0
- data/spec/citation_helper.rb +24 -29
- data/spec/citeproc/ruby/formats/adoc_spec.rb +2 -31
- data/spec/csl/styles/rfc_v2_spec.rb +22 -0
- data/spec/csl/styles/rfc_v3_spec.rb +22 -0
- data/spec/csl/styles/tex_citealp_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citealp_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citealps_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citealps_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citealt_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citealt_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citealts_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citealts_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citeauthor_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citeauthor_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citeauthors_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citeauthors_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citep_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citep_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citeps_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citeps_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citet_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citet_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citets_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citets_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citeyear_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citeyear_numeric_spec.rb +1 -1
- data/spec/csl/styles/tex_citeyearpar_authoryear_spec.rb +1 -1
- data/spec/csl/styles/tex_citeyearpar_numeric_spec.rb +1 -1
- data/spec/fixtures/database.bib +52 -0
- data/spec/fixtures/database.rfc.xml +86 -0
- data/spec/macros_spec.rb +3 -1
- data/spec/options_spec.rb +48 -0
- data/spec/sanity_spec.rb +1 -0
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee3b6315f9a710c52dd9b90d032bd6ea5f23c69c
|
4
|
+
data.tar.gz: c4cb88fc6f415e11bf87306ee0cb54f6011ef2c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8027a65944c8da37afa92525556f0a6e651d4a63a262ed68ce4e195ea88d54c5377f89a52b792834bd0493357d3d2e72883f6b601a64986cf6f9fe719eb02777
|
7
|
+
data.tar.gz: 0a3373d5c62e52d8badc699bf122fc46bad03b8a10938e9cca9f1eae89197a4d44b771ddbb2311ad726898e144468e070f7ac603e8e3805aee56a36f69424dfe
|
data/.oss-guides.rubocop.yml
CHANGED
@@ -74,10 +74,6 @@ Style/Encoding:
|
|
74
74
|
Description: Use UTF-8 as the source file encoding.
|
75
75
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#utf-8
|
76
76
|
Enabled: false
|
77
|
-
EnforcedStyle: always
|
78
|
-
SupportedStyles:
|
79
|
-
- when_needed
|
80
|
-
- always
|
81
77
|
Naming/FileName:
|
82
78
|
Description: Use snake_case for source file names.
|
83
79
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
@@ -997,10 +993,6 @@ Lint/HandleExceptions:
|
|
997
993
|
Description: Don't suppress exception.
|
998
994
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
999
995
|
Enabled: false
|
1000
|
-
Lint/InvalidCharacterLiteral:
|
1001
|
-
Description: Checks for invalid character literals with a non-escaped whitespace
|
1002
|
-
character.
|
1003
|
-
Enabled: false
|
1004
996
|
Lint/LiteralInCondition:
|
1005
997
|
Description: Checks of literals used in conditions.
|
1006
998
|
Enabled: false
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/README.adoc
CHANGED
@@ -324,6 +324,22 @@ Accepted values are `authoryear` (default) and `numeric`.
|
|
324
324
|
|
325
325
|
Furthermore, `fullcite` is also available and accepts no parameters except a single reference key.
|
326
326
|
|
327
|
+
==== Advanced options
|
328
|
+
|
329
|
+
When rendered citations (used at the beginning of a line) or references start with a special character, it might throw off `asciidoctor`. To avoid this an `{empty}` is prepended by default. Using the `bibliography-prepend-empty` you can decide whether to prepend it to citations (`citation`), references (`reference`), both (`true`) or neither (`false`). Default is `true`.
|
330
|
+
|
331
|
+
[source,asciidoc]
|
332
|
+
----
|
333
|
+
:bibliography-prepend-empty: true
|
334
|
+
----
|
335
|
+
|
336
|
+
Sometimes it is desirable to wrap the rendered citations in a passthrough. Using the `bibliography-passthrough` you can decide whether to wrap citations (`citation`), references (`reference`), both (`true`) or neither (`false`). They are wrapped in an inline passthrough (`+++`). Default is `false`.
|
337
|
+
|
338
|
+
[source,asciidoc]
|
339
|
+
----
|
340
|
+
:bibliography-passthrough: false
|
341
|
+
----
|
342
|
+
|
327
343
|
== Development
|
328
344
|
|
329
345
|
We follow Sandi Metz's Rules for this gem, you can read the
|
@@ -40,6 +40,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
40
40
|
spec.add_dependency "latex-decode", "~> 0.2.2"
|
41
41
|
spec.add_dependency "bibtex-ruby", "~> 4.4.4"
|
42
42
|
|
43
|
+
spec.add_dependency "nokogiri", "~> 1.8.1"
|
44
|
+
|
43
45
|
spec.add_development_dependency "bundler"
|
44
46
|
spec.add_development_dependency "byebug"
|
45
47
|
spec.add_development_dependency "rspec"
|
@@ -20,7 +20,6 @@ module AsciidoctorBibliography
|
|
20
20
|
@uuid = SecureRandom.uuid
|
21
21
|
@macro = macro
|
22
22
|
@citation_items = []
|
23
|
-
# rubocop:disable Performance/HashEachMethods
|
24
23
|
target_and_attributes_list_pairs.compact.each_slice(2).each do |target, attribute_list|
|
25
24
|
@citation_items << CitationItem.new do |cite|
|
26
25
|
cite.target = target.to_s.empty? ? "default" : target
|
@@ -31,24 +30,36 @@ module AsciidoctorBibliography
|
|
31
30
|
end
|
32
31
|
|
33
32
|
def render(bibliographer)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
formatted_citation =
|
34
|
+
case macro
|
35
|
+
when "cite"
|
36
|
+
render_citation_with_csl(bibliographer)
|
37
|
+
when "fullcite"
|
38
|
+
render_fullcite_with_csl(bibliographer)
|
39
|
+
when *TEX_MACROS
|
40
|
+
render_texmacro_with_csl(bibliographer)
|
41
|
+
end
|
42
|
+
wrap_up_citation citation: formatted_citation, bibliographer: bibliographer
|
43
|
+
end
|
44
|
+
|
45
|
+
def wrap_up_citation(citation:, bibliographer:)
|
46
|
+
text = citation.dup
|
47
|
+
# TODO: handle hyperlinks here, maybe?
|
48
|
+
text = ["+++", text, "+++"].join if bibliographer.options.passthrough?(:citation)
|
49
|
+
text.prepend "{empty}" if bibliographer.options.prepend_empty?(:citation)
|
50
|
+
text
|
51
|
+
end
|
52
|
+
|
53
|
+
def render_texmacro_with_csl(bibliographer)
|
54
|
+
filename = ["tex", macro.tr("*", "s"), bibliographer.options.tex_style].join("-")
|
55
|
+
filepath = File.join AsciidoctorBibliography.root, "lib/csl/styles", filename
|
56
|
+
render_citation_with_csl(bibliographer, style: filepath, tex: true)
|
44
57
|
end
|
45
58
|
|
46
59
|
def render_fullcite_with_csl(bibliographer)
|
47
60
|
formatter = Formatter.new(bibliographer.options.style, locale: bibliographer.options.locale)
|
48
61
|
prepare_fullcite_item bibliographer, formatter
|
49
|
-
|
50
|
-
# We prepend an empty interpolation to avoid interferences w/ standard syntax (e.g. block role is "\n[foo]")
|
51
|
-
"{empty}" + formatted_citation
|
62
|
+
formatter.render(:bibliography, id: citation_items.first.key).join
|
52
63
|
end
|
53
64
|
|
54
65
|
def prepare_fullcite_item(bibliographer, formatter)
|
@@ -60,8 +71,7 @@ module AsciidoctorBibliography
|
|
60
71
|
items = prepare_items bibliographer, formatter, tex: tex
|
61
72
|
formatted_citation = formatter.engine.renderer.render(items, formatter.engine.style.citation)
|
62
73
|
escape_brackets_inside_xref! formatted_citation
|
63
|
-
|
64
|
-
"{empty}" + formatted_citation
|
74
|
+
formatted_citation
|
65
75
|
end
|
66
76
|
|
67
77
|
def escape_brackets_inside_xref!(string)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "databases/bibtex"
|
2
|
+
require_relative "databases/rfc"
|
2
3
|
require_relative "errors"
|
3
4
|
|
4
5
|
module AsciidoctorBibliography
|
@@ -30,6 +31,8 @@ module AsciidoctorBibliography
|
|
30
31
|
case fileext
|
31
32
|
when *Databases::BibTeX::EXTENSIONS
|
32
33
|
Databases::BibTeX.load filepath
|
34
|
+
when *Databases::RFC::EXTENSIONS
|
35
|
+
Databases::RFC.load filepath
|
33
36
|
else
|
34
37
|
raise Errors::Database::UnsupportedFormat, fileext
|
35
38
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "nokogiri"
|
4
|
+
|
5
|
+
module AsciidoctorBibliography
|
6
|
+
module Databases
|
7
|
+
module RFC
|
8
|
+
EXTENSIONS = %w[.rfc .xml].freeze
|
9
|
+
|
10
|
+
MONTHS = %w{january february march april may june july
|
11
|
+
august september october november december}.freeze
|
12
|
+
|
13
|
+
def self.load(filename)
|
14
|
+
::Nokogiri::XML(File.open(filename)).
|
15
|
+
xpath("//reference").
|
16
|
+
map { |reference_tag| tag_to_citeproc reference_tag }
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.tag_to_citeproc(reference_tag)
|
20
|
+
{
|
21
|
+
"id" => reference_tag.attr("anchor"),
|
22
|
+
"author" => get_author_list(reference_tag),
|
23
|
+
"title" => reference_tag.xpath("//title").first&.text&.strip,
|
24
|
+
"issued" => {
|
25
|
+
"date-parts" => get_date_parts(reference_tag),
|
26
|
+
},
|
27
|
+
# NOTE: we keep the original XML to re-render it when needed
|
28
|
+
"note" => reference_tag.to_xml,
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.get_date_parts(reference_tag)
|
33
|
+
date_tag = reference_tag.xpath("//date").first
|
34
|
+
year = date_tag&.attr("year")
|
35
|
+
month = date_tag&.attr("month")
|
36
|
+
day = date_tag&.attr("day")
|
37
|
+
month = MONTHS.index(month.downcase) + 1 unless month.nil?
|
38
|
+
[year, month, day].take_while { |date_part| !date_part.nil? }.map(&:to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.get_author_list(reference_tag)
|
42
|
+
author_tags = reference_tag.xpath("//author")
|
43
|
+
author_tags.map do |author_tag|
|
44
|
+
{
|
45
|
+
"family" => author_tag&.attr("surname"),
|
46
|
+
"given" => author_tag&.attr("initials"),
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -18,11 +18,8 @@ module AsciidoctorBibliography
|
|
18
18
|
|
19
19
|
lines = []
|
20
20
|
formatter.bibliography.each_with_index do |reference, index|
|
21
|
-
line = "{empty}"
|
22
21
|
id = anchor_id "bibliography", target, formatter.data[index].id
|
23
|
-
|
24
|
-
line << reference
|
25
|
-
lines << line
|
22
|
+
lines << wrap_up_reference(reference: reference, id: id, bibliographer: bibliographer)
|
26
23
|
end
|
27
24
|
|
28
25
|
# Intersperse the lines with empty ones to render as paragraphs.
|
@@ -31,6 +28,14 @@ module AsciidoctorBibliography
|
|
31
28
|
|
32
29
|
private
|
33
30
|
|
31
|
+
def wrap_up_reference(reference:, id:, bibliographer:)
|
32
|
+
text = reference.dup
|
33
|
+
text.prepend "anchor:#{id}[]" if bibliographer.options.hyperlinks?
|
34
|
+
text = ["+++", reference, "+++"].join if bibliographer.options.passthrough?(:reference)
|
35
|
+
text.prepend "{empty}" if bibliographer.options.prepend_empty?(:reference)
|
36
|
+
text
|
37
|
+
end
|
38
|
+
|
34
39
|
def setup_formatter(bibliographer)
|
35
40
|
formatter = Formatter.new(bibliographer.options.style, locale: bibliographer.options.locale)
|
36
41
|
|
@@ -14,6 +14,8 @@ module AsciidoctorBibliography
|
|
14
14
|
"bibliography-order" => "alphabetical", # TODO: deprecate
|
15
15
|
"bibliography-tex-style" => "authoryear",
|
16
16
|
"bibliography-sort" => nil,
|
17
|
+
"bibliography-prepend-empty" => "true",
|
18
|
+
"bibliography-passthrough" => "false",
|
17
19
|
}.freeze
|
18
20
|
|
19
21
|
def initialize
|
@@ -38,42 +40,42 @@ module AsciidoctorBibliography
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def style
|
41
|
-
#
|
43
|
+
# First we check whether an internal style exists to qualify its path.
|
44
|
+
if self["bibliography-style"]
|
45
|
+
filepath = File.join AsciidoctorBibliography.csl_styles_root,
|
46
|
+
self["bibliography-style"] + ".csl"
|
47
|
+
self["bibliography-style"] = filepath if File.exist? filepath
|
48
|
+
end
|
49
|
+
# Then error throwing is delegated to CSL library.
|
42
50
|
self["bibliography-style"] || DEFAULTS["bibliography-style"]
|
43
51
|
end
|
44
52
|
|
45
53
|
def locale
|
46
54
|
value = self["bibliography-locale"] || DEFAULTS["bibliography-locale"]
|
47
|
-
unless CSL::Locale.list.include? value
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
MESSAGE
|
52
|
-
end
|
55
|
+
raise_invalid <<~MESSAGE unless CSL::Locale.list.include? value
|
56
|
+
Option :bibliography-locale: has an invalid value (#{value}).
|
57
|
+
Allowed values are #{CSL::Locale.list.inspect}.
|
58
|
+
MESSAGE
|
53
59
|
|
54
60
|
value
|
55
61
|
end
|
56
62
|
|
57
63
|
def hyperlinks?
|
58
64
|
value = self["bibliography-hyperlinks"] || DEFAULTS["bibliography-hyperlinks"]
|
59
|
-
unless %w[true false].include? value
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
MESSAGE
|
64
|
-
end
|
65
|
+
raise_invalid <<~MESSAGE unless %w[true false].include? value
|
66
|
+
Option :bibliography-hyperlinks: has an invalid value (#{value}).
|
67
|
+
Allowed values are 'true' and 'false'.
|
68
|
+
MESSAGE
|
65
69
|
|
66
70
|
value == "true"
|
67
71
|
end
|
68
72
|
|
69
73
|
def database
|
70
74
|
value = self["bibliography-database"] || DEFAULTS["bibliography-database"]
|
71
|
-
if value.nil?
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
MESSAGE
|
76
|
-
end
|
75
|
+
raise Errors::Options::Missing, <<~MESSAGE if value.nil?
|
76
|
+
Option :bibliography-database: is mandatory.
|
77
|
+
A bibliographic database is required.
|
78
|
+
MESSAGE
|
77
79
|
|
78
80
|
value
|
79
81
|
end
|
@@ -82,7 +84,7 @@ module AsciidoctorBibliography
|
|
82
84
|
begin
|
83
85
|
value = YAML.safe_load self["bibliography-sort"].to_s
|
84
86
|
rescue Psych::SyntaxError => psych_error
|
85
|
-
|
87
|
+
raise_invalid <<~MESSAGE
|
86
88
|
Option :bibliography-sort: is not a valid YAML string: \"#{psych_error}\".
|
87
89
|
MESSAGE
|
88
90
|
end
|
@@ -94,23 +96,54 @@ module AsciidoctorBibliography
|
|
94
96
|
|
95
97
|
def tex_style
|
96
98
|
value = self["bibliography-tex-style"] || DEFAULTS["bibliography-tex-style"]
|
97
|
-
unless %w[authoryear numeric].include? value
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
MESSAGE
|
102
|
-
end
|
99
|
+
raise_invalid <<~MESSAGE unless %w[authoryear numeric].include? value
|
100
|
+
Option :bibliography-tex-style: has an invalid value (#{value}).
|
101
|
+
Allowed values are 'authoryear' (default) and 'numeric'.
|
102
|
+
MESSAGE
|
103
103
|
|
104
104
|
value
|
105
105
|
end
|
106
106
|
|
107
|
+
def passthrough?(context)
|
108
|
+
# NOTE: allowed contexts are :citation and :reference
|
109
|
+
value = self["bibliography-passthrough"] || DEFAULTS["bibliography-passthrough"]
|
110
|
+
raise_invalid <<~MESSAGE unless %w[true citations references false].include? value
|
111
|
+
Option :bibliography-passthrough: has an invalid value (#{value}).
|
112
|
+
Allowed values are 'true', 'citations', 'references' and 'false'.
|
113
|
+
MESSAGE
|
114
|
+
|
115
|
+
evaluate_ext_boolean_value_vs_context value: value, context: context
|
116
|
+
end
|
117
|
+
|
118
|
+
def prepend_empty?(context)
|
119
|
+
# NOTE: allowed contexts are :citation and :reference
|
120
|
+
value = self["bibliography-prepend-empty"] || DEFAULTS["bibliography-prepend-empty"]
|
121
|
+
raise_invalid <<~MESSAGE unless %w[true citations references false].include? value
|
122
|
+
Option :bibliography-prepend-empty: has an invalid value (#{value}).
|
123
|
+
Allowed values are 'true', 'citations', 'references' and 'false'.
|
124
|
+
MESSAGE
|
125
|
+
|
126
|
+
evaluate_ext_boolean_value_vs_context value: value, context: context
|
127
|
+
end
|
128
|
+
|
107
129
|
private
|
108
130
|
|
131
|
+
def evaluate_ext_boolean_value_vs_context(value:, context:)
|
132
|
+
return true if value.to_s == "true"
|
133
|
+
return false if value.to_s == "false"
|
134
|
+
return context.to_s == "citation" if value.to_s == "citations"
|
135
|
+
return context.to_s == "reference" if value.to_s == "references"
|
136
|
+
end
|
137
|
+
|
138
|
+
def raise_invalid(message)
|
139
|
+
raise Errors::Options::Invalid, message
|
140
|
+
end
|
141
|
+
|
109
142
|
def validate_parsed_sort_type!(value)
|
110
143
|
return value if value.nil?
|
111
144
|
return value if value.is_a?(Array) && value.all? { |v| v.is_a? Hash }
|
112
145
|
return [value] if value.is_a? Hash
|
113
|
-
|
146
|
+
raise_invalid <<~MESSAGE
|
114
147
|
Option :bibliography-sort: has an invalid value (#{value}).
|
115
148
|
Please refer to manual for more info.
|
116
149
|
MESSAGE
|
@@ -120,7 +153,7 @@ module AsciidoctorBibliography
|
|
120
153
|
# TODO: should we restrict these? Double check the CSL spec.
|
121
154
|
allowed_keys = %w[variable macro sort names-min names-use-first names-use-last]
|
122
155
|
return array unless array.any? { |hash| (hash.keys - allowed_keys).any? }
|
123
|
-
|
156
|
+
raise_invalid <<~MESSAGE
|
124
157
|
Option :bibliography-sort: has a value containing invalid keys (#{array}).
|
125
158
|
Allowed keys are #{allowed_keys.inspect}.
|
126
159
|
Please refer to manual for more info.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
|
3
|
+
<info>
|
4
|
+
<title>RFC v2 style</title>
|
5
|
+
<id>rfc-v2</id>
|
6
|
+
<updated>2017-11-04T15:15:55+00:00</updated>
|
7
|
+
</info>
|
8
|
+
<macro name="citation-locator">
|
9
|
+
<group>
|
10
|
+
<label variable="locator" text-case="capitalize-first"/>
|
11
|
+
<text variable="locator" prefix=" "/>
|
12
|
+
</group>
|
13
|
+
</macro>
|
14
|
+
<citation>
|
15
|
+
<layout>
|
16
|
+
<group>
|
17
|
+
<group prefix="<xref" suffix=">">
|
18
|
+
<text variable="citation-label" prefix=" target="" suffix="""/>
|
19
|
+
</group>
|
20
|
+
<group delimiter=", ">
|
21
|
+
<text variable="citation-label" prefix="[" suffix="]"/>
|
22
|
+
<text macro="citation-locator"/>
|
23
|
+
</group>
|
24
|
+
<text value="</xref>"/>
|
25
|
+
</group>
|
26
|
+
</layout>
|
27
|
+
</citation>
|
28
|
+
<bibliography>
|
29
|
+
<layout>
|
30
|
+
<text variable="note"/>
|
31
|
+
</layout>
|
32
|
+
</bibliography>
|
33
|
+
</style>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
|
3
|
+
<info>
|
4
|
+
<title>RFC v3 style</title>
|
5
|
+
<id>rfc-v3</id>
|
6
|
+
<updated>2017-11-04T16:30:44+00:00</updated>
|
7
|
+
</info>
|
8
|
+
<macro name="citation-locator">
|
9
|
+
<group>
|
10
|
+
<label variable="locator" text-case="capitalize-first"/>
|
11
|
+
</group>
|
12
|
+
</macro>
|
13
|
+
<citation>
|
14
|
+
<layout>
|
15
|
+
<group delimiter=" " prefix="<relref " suffix="/>">
|
16
|
+
<text variable="citation-label" prefix="target="" suffix="""/>
|
17
|
+
<text variable="locator" prefix="section="" suffix="""/>
|
18
|
+
</group>
|
19
|
+
</layout>
|
20
|
+
</citation>
|
21
|
+
<bibliography>
|
22
|
+
<layout>
|
23
|
+
<text variable="note"/>
|
24
|
+
</layout>
|
25
|
+
</bibliography>
|
26
|
+
</style>
|
data/spec/citation_helper.rb
CHANGED
@@ -2,46 +2,41 @@
|
|
2
2
|
|
3
3
|
require "asciidoctor-bibliography"
|
4
4
|
|
5
|
-
|
6
|
-
@article{Erdos65,
|
7
|
-
title = {Some very hard sums},
|
8
|
-
journal={Difficult Maths Today},
|
9
|
-
author={Paul Erdős and Arend Heyting and Luitzen Egbertus Brouwer},
|
10
|
-
year={1965},
|
11
|
-
pages={30}
|
12
|
-
}
|
13
|
-
|
14
|
-
@article{Einstein35,
|
15
|
-
title={Can quantum-mechanical description of physical reality be considered complete?},
|
16
|
-
author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan},
|
17
|
-
journal={Physical review},
|
18
|
-
volume={47},
|
19
|
-
number={10},
|
20
|
-
pages={777},
|
21
|
-
year={1935},
|
22
|
-
publisher={APS}
|
23
|
-
}
|
24
|
-
BIBTEX
|
25
|
-
|
26
|
-
def init_bibliographer(bibtex_db:, options: {})
|
5
|
+
def init_bibliographer(options: {})
|
27
6
|
bibliographer = AsciidoctorBibliography::Bibliographer.new
|
28
7
|
|
29
|
-
|
30
|
-
merge("bibliography-hyperlinks" => "false").merge(options)
|
8
|
+
opts = options.dup
|
31
9
|
|
32
|
-
|
33
|
-
|
10
|
+
db_path = File.join __dir__, "fixtures", opts.delete("bibliography-database")
|
11
|
+
bibliographer.database = AsciidoctorBibliography::Database.new.append db_path
|
12
|
+
|
13
|
+
bibliographer.options =
|
14
|
+
AsciidoctorBibliography::Options.new.
|
15
|
+
merge(
|
16
|
+
"bibliography-hyperlinks" => "false",
|
17
|
+
"bibliography-prepend-empty" => "false",
|
18
|
+
).merge(opts)
|
34
19
|
|
35
20
|
bibliographer
|
36
21
|
end
|
37
22
|
|
38
23
|
def formatted_citation(macro, options: {})
|
39
|
-
bibliographer = init_bibliographer
|
40
|
-
options: options
|
24
|
+
bibliographer = init_bibliographer options: options
|
41
25
|
|
42
26
|
macro.gsub(AsciidoctorBibliography::Citation::REGEXP) do
|
43
27
|
citation = AsciidoctorBibliography::Citation.new(*Regexp.last_match.captures)
|
44
28
|
bibliographer.add_citation(citation)
|
45
29
|
citation.render bibliographer
|
46
|
-
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def formatted_bibliography(macro, options: {})
|
34
|
+
bibliographer = init_bibliographer options: options
|
35
|
+
macro.gsub(AsciidoctorBibliography::Citation::REGEXP) do
|
36
|
+
citation = AsciidoctorBibliography::Citation.new(*Regexp.last_match.captures)
|
37
|
+
bibliographer.add_citation(citation)
|
38
|
+
# citation.render bibliographer
|
39
|
+
index = AsciidoctorBibliography::Index.new("bibliography", "", "")
|
40
|
+
index.render(bibliographer).join
|
41
|
+
end
|
47
42
|
end
|
@@ -3,40 +3,11 @@
|
|
3
3
|
require "asciidoctor-bibliography"
|
4
4
|
require_relative "../../../citation_helper"
|
5
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
6
|
describe "custom :adoc citeproc format" do
|
36
|
-
let(:options) { { "bibliography-style" => "ieee" } }
|
7
|
+
let(:options) { { "bibliography-style" => "ieee", "bibliography-database" => "database.bib" } }
|
37
8
|
|
38
9
|
it "adds space between first and second field" do
|
39
|
-
expect(formatted_bibliography("
|
10
|
+
expect(formatted_bibliography("cite:[Gettier63]", options: options)).
|
40
11
|
to eq "[1] E. L. Gettier, “Is justified true belief knowledge?,” _analysis_, vol. 23, no. 6, pp. 121–123, 1963."
|
41
12
|
end
|
42
13
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require_relative "../../citation_helper"
|
4
|
+
|
5
|
+
describe "cite macro with rfc-v2 style" do
|
6
|
+
let(:options) { { "bibliography-style" => "rfc-v2", "bibliography-database" => "database.rfc.xml", "bibliography-passthrough" => "true", "bibliography-prepend-empty" => "false" } }
|
7
|
+
|
8
|
+
it "formats a single citation" do
|
9
|
+
expect(formatted_citation("cite:[RFC2119]", options: options)).
|
10
|
+
to eq '+++<xref target="RFC2119">[RFC2119]</xref>+++'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "formats a single citation with locator" do
|
14
|
+
expect(formatted_citation("cite:[RFC2119, section=1.2.3]", options: options)).
|
15
|
+
to eq '+++<xref target="RFC2119">[RFC2119], Section 1.2.3</xref>+++'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "formats a single bibliography entry" do
|
19
|
+
expect(formatted_bibliography("cite:[RFC2119]", options: options)).
|
20
|
+
to eq '+++<reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119"><front><title>Key words for use in RFCs to Indicate Requirement Levels</title><author initials="S." surname="Bradner" fullname="S. Bradner"><organization/></author><date year="1997" month="March"/><abstract><t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract></front><seriesInfo name="BCP" value="14"/><seriesInfo name="RFC" value="2119"/><seriesInfo name="DOI" value="10.17487/RFC2119"/></reference>+++'
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require_relative "../../citation_helper"
|
4
|
+
|
5
|
+
describe "cite macro with rfc-v3 style" do
|
6
|
+
let(:options) { { "bibliography-style" => "rfc-v3", "bibliography-database" => "database.rfc.xml", "bibliography-passthrough" => "true", "bibliography-prepend-empty" => "false" } }
|
7
|
+
|
8
|
+
it "formats a single citation" do
|
9
|
+
expect(formatted_citation("cite:[RFC2119]", options: options)).
|
10
|
+
to eq '+++<relref target="RFC2119"/>+++'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "formats a single citation with locator" do
|
14
|
+
expect(formatted_citation("cite:[RFC2119, section=1.2.3]", options: options)).
|
15
|
+
to eq '+++<relref target="RFC2119" section="1.2.3"/>+++'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "formats a single bibliography entry" do
|
19
|
+
expect(formatted_bibliography("cite:[RFC2119]", options: options)).
|
20
|
+
to eq '+++<reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119"><front><title>Key words for use in RFCs to Indicate Requirement Levels</title><author initials="S." surname="Bradner" fullname="S. Bradner"><organization/></author><date year="1997" month="March"/><abstract><t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract></front><seriesInfo name="BCP" value="14"/><seriesInfo name="RFC" value="2119"/><seriesInfo name="DOI" value="10.17487/RFC2119"/></reference>+++'
|
21
|
+
end
|
22
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealp macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealp:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealp macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealp:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealp* macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealp*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealp* macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealp*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealt macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealt:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealt macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealt:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealt* macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealt*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citealt* macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citealt*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeauthor macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeauthor:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeauthor macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeauthor:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeauthor* macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeauthor*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeauthor* macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeauthor*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citep macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citep:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citep macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citep:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citep* macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citep*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citep* macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citep*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citet macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citet:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citet macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citet:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citet* macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citet*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citet* macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citet*:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeyear macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeyear:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeyear macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeyear:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeyearpar macro with authoryear style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "authoryear" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "authoryear", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeyearpar:[Erdos65]", options: options)).
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../citation_helper"
|
4
4
|
|
5
5
|
describe "citeyearpar macro with numeric style" do
|
6
|
-
let(:options) { { "bibliography-tex-style" => "numeric" } }
|
6
|
+
let(:options) { { "bibliography-tex-style" => "numeric", "bibliography-database" => "database.bib" } }
|
7
7
|
|
8
8
|
it "formats a single citation" do
|
9
9
|
expect(formatted_citation("citeyearpar:[Erdos65]", options: options)).
|
data/spec/fixtures/database.bib
CHANGED
@@ -29,3 +29,55 @@
|
|
29
29
|
pages = {1036--1060},
|
30
30
|
year = {2004}
|
31
31
|
}
|
32
|
+
|
33
|
+
@article{Erdos65,
|
34
|
+
title = {Some very hard sums},
|
35
|
+
journal={Difficult Maths Today},
|
36
|
+
author={Paul Erdős and Arend Heyting and Luitzen Egbertus Brouwer},
|
37
|
+
year={1965},
|
38
|
+
pages={30}
|
39
|
+
}
|
40
|
+
|
41
|
+
@article{Einstein35,
|
42
|
+
title={Can quantum-mechanical description of physical reality be considered complete?},
|
43
|
+
author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan},
|
44
|
+
journal={Physical review},
|
45
|
+
volume={47},
|
46
|
+
number={10},
|
47
|
+
pages={777},
|
48
|
+
year={1935},
|
49
|
+
publisher={APS}
|
50
|
+
}
|
51
|
+
|
52
|
+
@article{Gettier63,
|
53
|
+
title={Is justified true belief knowledge?},
|
54
|
+
author={Gettier, Edmund L},
|
55
|
+
journal={analysis},
|
56
|
+
volume={23},
|
57
|
+
number={6},
|
58
|
+
pages={121--123},
|
59
|
+
year={1963},
|
60
|
+
publisher={JSTOR}
|
61
|
+
}
|
62
|
+
|
63
|
+
@techreport{iso:31000,
|
64
|
+
author = {ISO},
|
65
|
+
institution = {International Organization for Standardization},
|
66
|
+
address = {Geneva, Switzerland},
|
67
|
+
title = {Risk management---Principles and guidelines},
|
68
|
+
number = {31000:2009},
|
69
|
+
shorthand = {ISO 31000:2009},
|
70
|
+
type = {ISO},
|
71
|
+
year = {2009}
|
72
|
+
}
|
73
|
+
|
74
|
+
@techreport{iso:guide73,
|
75
|
+
author = {ISO},
|
76
|
+
institution = {International Organization for Standardization},
|
77
|
+
address = {Geneva, Switzerland},
|
78
|
+
title = {Risk management---Vocabulary},
|
79
|
+
number = {73:2009(E/F)},
|
80
|
+
shorthand = {ISO Guide 73:2009},
|
81
|
+
type = {ISO Guide},
|
82
|
+
year = {2013}
|
83
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<references>
|
2
|
+
<reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
|
3
|
+
<front>
|
4
|
+
<title>
|
5
|
+
Key words for use in RFCs to Indicate Requirement Levels
|
6
|
+
</title>
|
7
|
+
<author initials="S." surname="Bradner" fullname="S. Bradner">
|
8
|
+
<organization/>
|
9
|
+
</author>
|
10
|
+
<date year="1997" month="March"/>
|
11
|
+
<abstract>
|
12
|
+
<t>
|
13
|
+
In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.
|
14
|
+
</t>
|
15
|
+
</abstract>
|
16
|
+
</front>
|
17
|
+
<seriesInfo name="BCP" value="14"/>
|
18
|
+
<seriesInfo name="RFC" value="2119"/>
|
19
|
+
<seriesInfo name="DOI" value="10.17487/RFC2119"/>
|
20
|
+
</reference>
|
21
|
+
<reference anchor="RFC2629" target="https://www.rfc-editor.org/info/rfc2629">
|
22
|
+
<front>
|
23
|
+
<title>Writing I-Ds and RFCs using XML</title>
|
24
|
+
<author initials="M." surname="Rose" fullname="M. Rose">
|
25
|
+
<organization/>
|
26
|
+
</author>
|
27
|
+
<date year="1999" month="June"/>
|
28
|
+
<abstract>
|
29
|
+
<t>
|
30
|
+
This memo presents a technique for using XML (Extensible Markup Language) as a source format for documents in the Internet-Drafts (I-Ds) and Request for Comments (RFC) series. This memo provides information for the Internet community.
|
31
|
+
</t>
|
32
|
+
</abstract>
|
33
|
+
</front>
|
34
|
+
<seriesInfo name="RFC" value="2629"/>
|
35
|
+
<seriesInfo name="DOI" value="10.17487/RFC2629"/>
|
36
|
+
</reference>
|
37
|
+
<reference anchor="RFC3552" target="https://www.rfc-editor.org/info/rfc3552">
|
38
|
+
<front>
|
39
|
+
<title>
|
40
|
+
Guidelines for Writing RFC Text on Security Considerations
|
41
|
+
</title>
|
42
|
+
<author initials="E." surname="Rescorla" fullname="E. Rescorla">
|
43
|
+
<organization/>
|
44
|
+
</author>
|
45
|
+
<author initials="B." surname="Korver" fullname="B. Korver">
|
46
|
+
<organization/>
|
47
|
+
</author>
|
48
|
+
<date year="2003" month="July"/>
|
49
|
+
<abstract>
|
50
|
+
<t>
|
51
|
+
All RFCs are required to have a Security Considerations section. Historically, such sections have been relatively weak. This document provides guidelines to RFC authors on how to write a good Security Considerations section. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.
|
52
|
+
</t>
|
53
|
+
</abstract>
|
54
|
+
</front>
|
55
|
+
<seriesInfo name="BCP" value="72"/>
|
56
|
+
<seriesInfo name="RFC" value="3552"/>
|
57
|
+
<seriesInfo name="DOI" value="10.17487/RFC3552"/>
|
58
|
+
</reference>
|
59
|
+
<reference anchor="RFC5226" target="https://www.rfc-editor.org/info/rfc5226">
|
60
|
+
<front>
|
61
|
+
<title>
|
62
|
+
Guidelines for Writing an IANA Considerations Section in RFCs
|
63
|
+
</title>
|
64
|
+
<author initials="T." surname="Narten" fullname="T. Narten">
|
65
|
+
<organization/>
|
66
|
+
</author>
|
67
|
+
<author initials="H." surname="Alvestrand" fullname="H. Alvestrand">
|
68
|
+
<organization/>
|
69
|
+
</author>
|
70
|
+
<date year="2008" month="May"/>
|
71
|
+
<abstract>
|
72
|
+
<t>
|
73
|
+
Many protocols make use of identifiers consisting of constants and other well-known values. Even after a protocol has been defined and deployment has begun, new values may need to be assigned (e.g., for a new option type in DHCP, or a new encryption or authentication transform for IPsec). To ensure that such quantities have consistent values and interpretations across all implementations, their assignment must be administered by a central authority. For IETF protocols, that role is provided by the Internet Assigned Numbers Authority (IANA).
|
74
|
+
</t>
|
75
|
+
<t>
|
76
|
+
In order for IANA to manage a given namespace prudently, it needs guidelines describing the conditions under which new values can be assigned or when modifications to existing values can be made. If IANA is expected to play a role in the management of a namespace, IANA must be given clear and concise instructions describing that role. This document discusses issues that should be considered in formulating a policy for assigning values to a namespace and provides guidelines for authors on the specific text that must be included in documents that place demands on IANA.
|
77
|
+
</t>
|
78
|
+
<t>
|
79
|
+
This document obsoletes RFC 2434. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.
|
80
|
+
</t>
|
81
|
+
</abstract>
|
82
|
+
</front>
|
83
|
+
<seriesInfo name="RFC" value="5226"/>
|
84
|
+
<seriesInfo name="DOI" value="10.17487/RFC5226"/>
|
85
|
+
</reference>
|
86
|
+
</references>
|
data/spec/macros_spec.rb
CHANGED
@@ -6,6 +6,7 @@ describe "cite macro with apa style" do
|
|
6
6
|
it "formats a complex citation" do
|
7
7
|
expect(formatted_citation("cite:[Erdos65, prefix=see]+[Einstein35, page=41-43]",
|
8
8
|
options: { "bibliography-style" => "apa",
|
9
|
+
"bibliography-database" => "database.bib",
|
9
10
|
"bibliography-hyperlinks" => "true" })).
|
10
11
|
to eq "(xref:bibliography-default-Einstein35[Einstein, Podolsky, & Rosen, 1935, pp. 41-43]; " +
|
11
12
|
"xref:bibliography-default-Erdos65[seeErdős, Heyting, & Brouwer, 1965])"
|
@@ -15,7 +16,8 @@ end
|
|
15
16
|
describe "fullcite macro with apa style" do
|
16
17
|
it "formats a complex citation" do
|
17
18
|
expect(formatted_citation("fullcite:[Erdos65]",
|
18
|
-
options: { "bibliography-style" => "apa"
|
19
|
+
options: { "bibliography-style" => "apa",
|
20
|
+
"bibliography-database" => "database.bib" })).
|
19
21
|
to eq "Erdős, P., Heyting, A., & Brouwer, L. E. (1965). Some very hard sums. _Difficult Maths Today_, 30."
|
20
22
|
end
|
21
23
|
end
|
data/spec/options_spec.rb
CHANGED
@@ -12,6 +12,54 @@ describe AsciidoctorBibliography::Options do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe "#prepend_empty?" do
|
16
|
+
it "defaults to true" do
|
17
|
+
expect(described_class.new.prepend_empty?(:citation)).to be true
|
18
|
+
expect(described_class.new.prepend_empty?(:reference)).to be true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns true when provided option is true" do
|
22
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "true").
|
23
|
+
prepend_empty?(:citation)).to be true
|
24
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "true").
|
25
|
+
prepend_empty?(:reference)).to be true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns true for citations when provided option is citations" do
|
29
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "citations").
|
30
|
+
prepend_empty?(:citation)).to be true
|
31
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "citations").
|
32
|
+
prepend_empty?(:reference)).to be false
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns true for references when provided option is references" do
|
36
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "references").
|
37
|
+
prepend_empty?(:citation)).to be false
|
38
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "references").
|
39
|
+
prepend_empty?(:reference)).to be true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns false when provided option is false" do
|
43
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "false").
|
44
|
+
prepend_empty?(:citation)).to be false
|
45
|
+
expect(described_class.new.merge("bibliography-prepend-empty" => "false").
|
46
|
+
prepend_empty?(:reference)).to be false
|
47
|
+
end
|
48
|
+
|
49
|
+
it "raises an error when provided option is invalid" do
|
50
|
+
expect do
|
51
|
+
described_class.new.merge("bibliography-prepend-empty" => "foo").
|
52
|
+
prepend_empty?(:citation)
|
53
|
+
end.
|
54
|
+
to raise_exception AsciidoctorBibliography::Errors::Options::Invalid
|
55
|
+
expect do
|
56
|
+
described_class.new.merge("bibliography-prepend-empty" => "foo").
|
57
|
+
prepend_empty?(:reference)
|
58
|
+
end.
|
59
|
+
to raise_exception AsciidoctorBibliography::Errors::Options::Invalid
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
15
63
|
describe "#hyperlinks?" do
|
16
64
|
it "defaults to true" do
|
17
65
|
expect(described_class.new.hyperlinks?).to be true
|
data/spec/sanity_spec.rb
CHANGED
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 4.4.4
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.8.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.8.1
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: bundler
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,12 +233,15 @@ files:
|
|
219
233
|
- lib/asciidoctor-bibliography/citation_item.rb
|
220
234
|
- lib/asciidoctor-bibliography/database.rb
|
221
235
|
- lib/asciidoctor-bibliography/databases/bibtex.rb
|
236
|
+
- lib/asciidoctor-bibliography/databases/rfc.rb
|
222
237
|
- lib/asciidoctor-bibliography/errors.rb
|
223
238
|
- lib/asciidoctor-bibliography/formatter.rb
|
224
239
|
- lib/asciidoctor-bibliography/index.rb
|
225
240
|
- lib/asciidoctor-bibliography/options.rb
|
226
241
|
- lib/asciidoctor-bibliography/version.rb
|
227
242
|
- lib/citeproc/ruby/formats/adoc.rb
|
243
|
+
- lib/csl/styles/rfc-v2.csl
|
244
|
+
- lib/csl/styles/rfc-v3.csl
|
228
245
|
- lib/csl/styles/tex-citealp-authoryear.csl
|
229
246
|
- lib/csl/styles/tex-citealp-numeric.csl
|
230
247
|
- lib/csl/styles/tex-citealps-authoryear.csl
|
@@ -268,6 +285,8 @@ files:
|
|
268
285
|
- spec/citation_helper.rb
|
269
286
|
- spec/citation_item_spec.rb
|
270
287
|
- spec/citeproc/ruby/formats/adoc_spec.rb
|
288
|
+
- spec/csl/styles/rfc_v2_spec.rb
|
289
|
+
- spec/csl/styles/rfc_v3_spec.rb
|
271
290
|
- spec/csl/styles/tex_citealp_authoryear_spec.rb
|
272
291
|
- spec/csl/styles/tex_citealp_numeric_spec.rb
|
273
292
|
- spec/csl/styles/tex_citealps_authoryear_spec.rb
|
@@ -295,6 +314,7 @@ files:
|
|
295
314
|
- spec/database_spec.rb
|
296
315
|
- spec/fixtures/database.bib
|
297
316
|
- spec/fixtures/database.bibtex
|
317
|
+
- spec/fixtures/database.rfc.xml
|
298
318
|
- spec/fixtures/database.unk
|
299
319
|
- spec/macros_spec.rb
|
300
320
|
- spec/options_spec.rb
|