asciidoctor-bibtex 0.7.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +6 -1
- data/lib/asciidoctor-bibtex/extensions.rb +20 -11
- data/lib/asciidoctor-bibtex/processor.rb +2 -2
- data/lib/asciidoctor-bibtex/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea06f24608939a234d65f9d138406f453db0839bd70cf334f81def2dd85d52f0
|
4
|
+
data.tar.gz: 322af457bcfa3597a57268b2ea186ed1800bf1138189f0393d379e56dd743f87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57d7f51eaf2b99a100e827e5efb5ce4f6548573dd9eef70aef0347ed687e590c43d51ced0f5f8c3bdbae2681386bfebf827781f2f7d6297a92d9854bc03c2d8b
|
7
|
+
data.tar.gz: f2895e57fe0f6c85b07cf26e53c4011e61a9c613489b0cc755065c04d55daf670665a8a143e60e73d39fa432b64a1f62ad19719065c5415a9cd126b9eee44d82
|
data/README.adoc
CHANGED
@@ -20,7 +20,7 @@ endif::[]
|
|
20
20
|
:url-gem: https://rubygems.org/gems/asciidoctor-bibtex
|
21
21
|
|
22
22
|
ifdef::status[]
|
23
|
-
image:https://
|
23
|
+
image:https://github.com/asciidoctor/asciidoctor-bibtex/workflows/CI/badge.svg[GitHub Actions Status,link=https://github.com/asciidoctor/asciidoctor-bibtex/actions]
|
24
24
|
image:https://img.shields.io/gem/v/asciidoctor-bibtex.svg[Latest Release, link=https://rubygems.org/gems/asciidoctor-bibtex]
|
25
25
|
endif::[]
|
26
26
|
|
@@ -125,6 +125,11 @@ Configuration is applied in the form of AsciiDoc document attributes, which must
|
|
125
125
|
| `asciidoc`, `bibtex` or `biblatex`
|
126
126
|
| `asciidoc`
|
127
127
|
|
128
|
+
| bibtex-locale
|
129
|
+
| Locale used to render the bibliography
|
130
|
+
| strings supported by CSL
|
131
|
+
| `en-US`
|
132
|
+
|
128
133
|
| bibtex-throw
|
129
134
|
| Throw an error on unknown references
|
130
135
|
| `true` or `false`
|
@@ -13,7 +13,7 @@ require_relative 'processor'
|
|
13
13
|
module AsciidoctorBibtex
|
14
14
|
module Asciidoctor
|
15
15
|
# Placeholder paragraph for the bibliography paragraph. Choose a uuid so
|
16
|
-
# that it is a special word
|
16
|
+
# that it is a special word unlikely to conflict with normal texts.
|
17
17
|
BibliographyBlockMacroPlaceholder = %(a5d42deb-3cfc-4293-b96a-fcb47316ce56)
|
18
18
|
|
19
19
|
# BibliographyBlockMacro
|
@@ -32,7 +32,7 @@ module AsciidoctorBibtex
|
|
32
32
|
|
33
33
|
def process(parent, target, attrs)
|
34
34
|
# NOTE: bibtex-file and bibtex-style set by this macro shall be
|
35
|
-
# overridable by document attributes and
|
35
|
+
# overridable by document attributes and command line arguments. So we
|
36
36
|
# respect the convention here.
|
37
37
|
if target && (!parent.document.attr? 'bibtex-file')
|
38
38
|
parent.document.set_attribute 'bibtex-file', target
|
@@ -53,7 +53,7 @@ module AsciidoctorBibtex
|
|
53
53
|
#
|
54
54
|
# This processor scans the document, generates a list of citations, replaces
|
55
55
|
# each citation with citation text and the reference block macro placeholder
|
56
|
-
# with the final bibliography list. It
|
56
|
+
# with the final bibliography list. It relies on the block macro processor to
|
57
57
|
# generate the place holder.
|
58
58
|
#
|
59
59
|
# NOTE: According to the asiidoctor extension policy, the tree processor can
|
@@ -70,6 +70,9 @@ module AsciidoctorBibtex
|
|
70
70
|
bibtex_citation_template = ((document.attr 'bibtex-citation-template') || '[$id]').to_s
|
71
71
|
|
72
72
|
# Fild bibtex file automatically if not supplied.
|
73
|
+
if bibtex_file.empty?
|
74
|
+
bibtex_file = AsciidoctorBibtex::PathUtils.find_bibfile document.base_dir
|
75
|
+
end
|
73
76
|
if bibtex_file.empty?
|
74
77
|
bibtex_file = AsciidoctorBibtex::PathUtils.find_bibfile '.'
|
75
78
|
end
|
@@ -82,7 +85,7 @@ module AsciidoctorBibtex
|
|
82
85
|
end
|
83
86
|
|
84
87
|
# Extract all AST nodes that can contain citations.
|
85
|
-
prose_blocks = document.find_by do |b|
|
88
|
+
prose_blocks = document.find_by traverse_documents: true do |b|
|
86
89
|
(b.content_model == :simple) ||
|
87
90
|
(b.context == :list_item) ||
|
88
91
|
(b.context == :table_cell) ||
|
@@ -97,7 +100,10 @@ module AsciidoctorBibtex
|
|
97
100
|
# First pass: extract all citations.
|
98
101
|
prose_blocks.each do |block|
|
99
102
|
if block.context == :list_item || block.context == :table_cell
|
100
|
-
|
103
|
+
# NOTE: we access the instance variable @text for raw text.
|
104
|
+
# Otherwise the footnotes in the text will be pre-processed and
|
105
|
+
# ghost footnotes will be inserted (as of asciidoctor 2.0.10).
|
106
|
+
line = block.instance_variable_get(:@text)
|
101
107
|
unless line.nil? || line.empty?
|
102
108
|
processor.process_citation_macros line
|
103
109
|
end
|
@@ -106,7 +112,7 @@ module AsciidoctorBibtex
|
|
106
112
|
processor.process_citation_macros line
|
107
113
|
end
|
108
114
|
else
|
109
|
-
line = block.title
|
115
|
+
line = block.instance_variable_get(:@title)
|
110
116
|
processor.process_citation_macros line
|
111
117
|
end
|
112
118
|
end
|
@@ -119,22 +125,25 @@ module AsciidoctorBibtex
|
|
119
125
|
# NOTE: we access the instance variable @text for raw text.
|
120
126
|
line = block.instance_variable_get(:@text)
|
121
127
|
unless line.nil? or line.empty?
|
128
|
+
line_orig = line
|
122
129
|
line = processor.replace_citation_macros(line)
|
123
130
|
line = processor.replace_bibitem_macros(line)
|
124
|
-
block.text = line
|
131
|
+
block.text = line if line != line_orig
|
125
132
|
end
|
126
133
|
elsif block.content_model == :simple
|
127
134
|
block.lines.each_with_index do |line, index|
|
135
|
+
line_orig = line
|
128
136
|
line = processor.replace_citation_macros(line)
|
129
137
|
line = processor.replace_bibitem_macros(line)
|
130
|
-
block.lines[index] = line
|
138
|
+
block.lines[index] = line if line != line_orig
|
131
139
|
end
|
132
140
|
else
|
133
141
|
# NOTE: we access the instance variable @text for raw text.
|
134
142
|
line = block.instance_variable_get(:@title)
|
143
|
+
line_orig = line
|
135
144
|
line = processor.replace_citation_macros(line)
|
136
|
-
|
137
|
-
block.title = line
|
145
|
+
line = processor.replace_bibitem_macros(line)
|
146
|
+
block.title = line if line != line_orig
|
138
147
|
end
|
139
148
|
end
|
140
149
|
|
@@ -150,7 +159,7 @@ module AsciidoctorBibtex
|
|
150
159
|
|
151
160
|
# Third pass: replace the bibliography paragraph with the bibliography
|
152
161
|
# list.
|
153
|
-
biblio_blocks = document.find_by do |b|
|
162
|
+
biblio_blocks = document.find_by traverse_documents: true do |b|
|
154
163
|
# for fast search (since most searches shall fail)
|
155
164
|
(b.content_model == :simple) && (b.lines.size == 1) \
|
156
165
|
&& (b.lines[0] == BibliographyBlockMacroPlaceholder)
|
@@ -207,7 +207,7 @@ module AsciidoctorBibtex
|
|
207
207
|
'textcite'
|
208
208
|
else
|
209
209
|
'parencite'
|
210
|
-
|
210
|
+
end
|
211
211
|
else
|
212
212
|
'cite'
|
213
213
|
end
|
@@ -260,7 +260,7 @@ module AsciidoctorBibtex
|
|
260
260
|
result = StringUtils.combine_consecutive_numbers(result)
|
261
261
|
end
|
262
262
|
|
263
|
-
include_pretext
|
263
|
+
"[.citation]\##{include_pretext(result, macro, ob, cb)}\#"
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-bibtex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhang YANG
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '6.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: citeproc-ruby
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,7 +135,7 @@ homepage: https://github.com/asciidoctor/asciidoctor-bibtex
|
|
135
135
|
licenses:
|
136
136
|
- OWL
|
137
137
|
metadata: {}
|
138
|
-
post_install_message:
|
138
|
+
post_install_message:
|
139
139
|
rdoc_options: []
|
140
140
|
require_paths:
|
141
141
|
- lib
|
@@ -143,15 +143,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements:
|
144
144
|
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: 2.
|
146
|
+
version: 2.4.0
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - ">="
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
154
|
-
signing_key:
|
153
|
+
rubygems_version: 3.3.26
|
154
|
+
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: An Asciidoctor extension that adds bibtex integration to AsciiDoc
|
157
157
|
test_files: []
|