asciidoctor-bibtex 0.5.2 → 0.6.0

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: 961c0ec9cfd281aab9ea43e5191ff9ad845849fd851a61625329c0676099f246
4
- data.tar.gz: c968cd134fcf4696af048c5c30c2316b93e7fcde050b6230581063e9ccdd44d5
3
+ metadata.gz: bccdd37cd3c92456c39f42cb27ea3b0605a03d72d465252993997e97d5c22550
4
+ data.tar.gz: 172ad52204430a2672cbb19d0c4206bd12127ab8aae7eb52a1110b7aa245734e
5
5
  SHA512:
6
- metadata.gz: de2d39bd265c5e4f114d41cd3d9b2d0a8ea6f70ef416a2a631ee316a1005ae397ecc0e0d0bac57a17193a2e69654d88469e3b1cb10c1e679ae943998ae42fc86
7
- data.tar.gz: b57e19aa3ca7365e1f1e6f5f94dcfc9cabc53247212f4be0fe40e22708733ab320c02676170509562c4a77914d88dd9038be50a0eea4cb6c62b66ff15db88bfd
6
+ metadata.gz: 43c2d4492d39072ec712873f0414f5ba988f864a7fc7e9883decefba673357f650667a37d410506335d66c3d7524ebcb2d6686c2d4b3e24a8e2eced503432e61
7
+ data.tar.gz: 8a14439358c611b4535942882978581f9957faf43519616c760a4f9a2b3307e923a3d59fa8550d7ecde37c0598dd51d658d444dee8b340506ab939c47e13dfc5
@@ -0,0 +1,126 @@
1
+ = asciidoctor-bibtex: bibtex integration for AsciiDoc
2
+ // Settings:
3
+ :idprefix:
4
+ :idseparator: -
5
+ ifndef::env-github[:icons: font]
6
+ ifdef::env-github,env-browser[]
7
+ :toc: macro
8
+ :toclevels: 1
9
+ endif::[]
10
+ ifdef::env-github[]
11
+ :!toc-title:
12
+ endif::[]
13
+ // URLs:
14
+ :url-asciidoctor: http://asciidoctor.org
15
+ :url-asciidoctor-mathematical: https://github.com/asciidoctor/asciidoctor-mathematical
16
+ :url-asciidoctor-pdf: https://github.com/asciidoctor/asciidoctor-pdf
17
+ :url-asciidoctor-latex: https://github.com/asciidoctor/asciidoctor-latex
18
+ :url-asciidoc-bib: https://github.com/petercrlane/asciidoc-bib
19
+
20
+ asciidoctor-bibtex adds bibtex integration to AsciiDoc documents by introducing two new macros: `cite:[KEY]` and `bibliography::[]`.
21
+ Citations are parsed and replaced with formatted inline texts, and reference lists are automatically generated and inserted into where `bibliography::[]` is placed.
22
+
23
+ asciidoctor-bibtex is designed to be used as an extension to {url-asciidoctor}[Asciidoctor].
24
+ Thus this extension can be used together with other asciidoctor extensions such as {url-asciidoctor-mathematical}[asciidoctor-mathematical] and {url-asciidoctor-pdf}[asciidoctor-pdf] to enrich your AsciiDoc experience.
25
+
26
+ NOTE: asciidoctor-bibtex no longer supports AsciiDoc-to-AsciiDoc conversion.
27
+
28
+ == History
29
+
30
+ asciidoctor-bibtex starts as a fork of {url-asciidoc-bib}[asciidoc-bib] and goes along a different path.
31
+ The major reason for the fork at the time was the differences in citation and bibliography macros.
32
+ asciidoc-bib failed to follow the grammar of macros in AsciiDoc and thus caused problems with existing documents and extensions.
33
+ Thus, a fork was needed.
34
+ Another reason was the inability to pass configuration via AsciiDoc attributes.
35
+
36
+ While {url-asciidoc-bib}[asciidoc-bib] focuses on replacing citations in the original documents and produces new AsciiDoc documents, asciidoctor-bibtex focuses on compatibility with Asciidoctor and other Asciidoctor extensions at the very beginning.
37
+ As time passes, asciidoctor-bibtex diverges significantly from its ancesstor.
38
+ For example, asciidoctor-bibtex now supports generating real bibtex citations and bibliography, so it can be used together with {url-asciidoctor-latex}[asciidoctor-latex] for native bibtex support.
39
+
40
+ == Install
41
+
42
+ $ gem install asciidoctor-bibtex
43
+
44
+ asciidoctor-bibtex depends on https://github.com/inukshuk/bibtex-ruby[bibtex-ruby], https://github.com/inukshuk/citeproc-ruby[citeproc-ruby], and https://github.com/inukshuk/csl-styles[csl-styles].
45
+ Ensure the `ruby-dev` and `libxslt1-dev` packages are installed on your machine so the dependencies will compile properly.
46
+
47
+ {url-asciidoctor}[Asciidoctor] must also be installed for 'asciidoctor-bibtex' to work.
48
+ Asciidoctor version 1.5.2 or higher is required.
49
+
50
+ == Usage
51
+
52
+ First, you need to have a valid bibtex file.
53
+ You specify the location to this file using the `bibtex-file` document attribute.
54
+
55
+ === Macros
56
+
57
+ Syntax for inserting a citation is the following inline macro:
58
+
59
+ cite|citenp:[ref(pages), ...]
60
+
61
+ where '(pages)' is optional.
62
+
63
+ Examples of "chicago-author-date" style:
64
+
65
+ * `cite:[Lane12]` becomes "(Lane 2012)"
66
+ * `citenp:[Lane12]` becomes "Lane (2012)"
67
+ * `cite:[Lane12(59)]` becomes "(Lane 2012, 59)"
68
+
69
+ For *apa* (Harvard-like) style:
70
+
71
+ * `cite:[Lane12]` becomes "(Lane, 2012)"
72
+ * `citenp:[Lane12]` becomes "Lane (2012)"
73
+ * `cite:[Lane12(59)]` becomes "(Lane, 2012, p.59)"
74
+
75
+ For *ieee*, a numeric style:
76
+
77
+ `cite:[Lane12,Lane11]` becomes "[1, 2]"
78
+
79
+ To add a list of formatted references, place `bibliography::[]` on a line by itself.
80
+
81
+ === Configuration
82
+
83
+ Configuration is applied in the form of AsciiDoc document attributes, which must be defined in the document header.
84
+
85
+ |===
86
+ | Attribute Name | Description | Valid Values | Default Value
87
+
88
+ | bibtex-file
89
+ | Bibtex database file
90
+ | any string, or empty
91
+ | Automatic searching
92
+
93
+ | bibtex-style
94
+ | Reference formatting style
95
+ | any style supported by csl-styles
96
+ | ieee
97
+
98
+ | bibtex-order
99
+ | Order of citations
100
+ | `appearance` or `alphabetical`
101
+ | `appearance`
102
+
103
+ | bibtex-format
104
+ | Formatting of citations and bibliography
105
+ | `asciidoc`, `bibtex` or `biblatex`
106
+ | `asciidoc`
107
+
108
+ | bibtex-throw
109
+ | Throw an error on unknown references
110
+ | `true` or `false`
111
+ | `false`
112
+ |===
113
+
114
+ === Commandline
115
+
116
+ Use asciidoctor-bibtex as an extension with the CLI:
117
+
118
+ $ asciidoctor -r asciidoctor-bibtex sample.adoc
119
+
120
+ == License
121
+
122
+ The files within this project may be distributed under the terms of the http://owl.apotheon.org[Open Works License].
123
+
124
+ == Links
125
+
126
+ See {url-asciidoc-bib} for the original asciidoc-bib source.
@@ -7,8 +7,8 @@ require 'asciidoctor/extensions'
7
7
  require 'asciidoctor/reader'
8
8
  require 'asciidoctor/parser'
9
9
 
10
- require_relative 'PathUtils'
11
- require_relative 'Processor'
10
+ require_relative 'path_utils'
11
+ require_relative 'processor'
12
12
 
13
13
  module AsciidoctorBibtex
14
14
  module Asciidoctor
@@ -109,12 +109,11 @@ module AsciidoctorBibtex
109
109
  # Second pass: replace citations with citation texts.
110
110
  prose_blocks.each do |block|
111
111
  if block.context == :list_item || block.context == :table_cell
112
- # NOTE: we access the instance variable @text directly to prevent
113
- # asciidoctor from changing the raw texts.
112
+ # NOTE: we access the instance variable @text for raw text.
114
113
  line = block.instance_variable_get(:@text)
115
114
  if !line.empty?
116
115
  line = processor.replace_citation_macros(line)
117
- block.instance_variable_set(:@text, line)
116
+ block.text = line
118
117
  end
119
118
  else
120
119
  block.lines.each_with_index do |line, index|
@@ -16,10 +16,10 @@ require 'latex/decode/symbols'
16
16
  require 'latex/decode/greek'
17
17
  require 'set'
18
18
 
19
- require_relative 'CitationMacro'
20
- require_relative 'CitationUtils'
21
- require_relative 'StringUtils'
22
- require_relative 'StyleUtils'
19
+ require_relative 'citation_macro'
20
+ require_relative 'citation_utils'
21
+ require_relative 'string_utils'
22
+ require_relative 'style_utils'
23
23
 
24
24
  module AsciidoctorBibtex
25
25
  # This filter extends the original latex filter in bibtex-ruby to handle
@@ -97,7 +97,10 @@ module AsciidoctorBibtex
97
97
  # Remove { } from grouped names for sorting.
98
98
  author = bibitem.author
99
99
  author = bibitem.editor if author.nil?
100
- CitationUtils.author_chicago(author).collect { |s| s.upcase.gsub('{', '').gsub('}', '') } + [bibitem.year]
100
+ year = bibitem.year
101
+ sortable = CitationUtils.author_chicago(author).map { |s| s.upcase.delete '{}' }
102
+ sortable << year if year
103
+ sortable
101
104
  end
102
105
  end
103
106
  nil
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibtex
2
- VERSION = '0.5.2'
2
+ VERSION = '0.6.0'
3
3
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-bibtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhang YANG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2019-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 2.0.0
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: 3.0.0
19
+ version: '2.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 2.0.0
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 3.0.0
26
+ version: '2.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: bibtex-ruby
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,63 +86,49 @@ dependencies:
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: '5'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '5'
103
- - !ruby/object:Gem::Dependency
104
- name: bundler
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '2'
89
+ version: 5.11.0
110
90
  type: :development
111
91
  prerelease: false
112
92
  version_requirements: !ruby/object:Gem::Requirement
113
93
  requirements:
114
94
  - - "~>"
115
95
  - !ruby/object:Gem::Version
116
- version: '2'
96
+ version: 5.11.0
117
97
  - !ruby/object:Gem::Dependency
118
98
  name: rake
119
99
  requirement: !ruby/object:Gem::Requirement
120
100
  requirements:
121
101
  - - "~>"
122
102
  - !ruby/object:Gem::Version
123
- version: '12'
103
+ version: 12.3.0
124
104
  type: :development
125
105
  prerelease: false
126
106
  version_requirements: !ruby/object:Gem::Requirement
127
107
  requirements:
128
108
  - - "~>"
129
109
  - !ruby/object:Gem::Version
130
- version: '12'
131
- description: |
132
- asciidoctor-bibtex adds bibtex support for asciidoc documents by introducing
133
- two new macros: `cite:[KEY]` and `bibliography::[]`. Citations are parsed and
134
- replaced with formatted inline texts, and reference lists are automatically
135
- generated and inserted into where `bibliography::[]` is placed. The
136
- references are formatted using styles provided by CSL.
137
- email: zyangmath@gmail.com
110
+ version: 12.3.0
111
+ description: 'asciidoctor-bibtex is an Asciidocotor extension that adds bibtex support
112
+ for AsciiDoc documents. It does so by introducing two new macros: `cite:[KEY]` and
113
+ `bibliography::[]`. Citations are parsed and replaced with formatted inline text,
114
+ and reference lists are automatically generated and inserted where the `bibliography::[]`
115
+ macro is placed. The references are formatted using styles provided by CSL.'
116
+ email:
117
+ - zyangmath@gmail.com
138
118
  executables: []
139
119
  extensions: []
140
120
  extra_rdoc_files: []
141
121
  files:
142
122
  - LICENSE.txt
143
- - README.md
123
+ - README.adoc
144
124
  - lib/asciidoctor-bibtex.rb
145
- - lib/asciidoctor-bibtex/CitationMacro.rb
146
- - lib/asciidoctor-bibtex/CitationUtils.rb
147
- - lib/asciidoctor-bibtex/PathUtils.rb
148
- - lib/asciidoctor-bibtex/Processor.rb
149
- - lib/asciidoctor-bibtex/StringUtils.rb
150
- - lib/asciidoctor-bibtex/StyleUtils.rb
125
+ - lib/asciidoctor-bibtex/citation_macro.rb
126
+ - lib/asciidoctor-bibtex/citation_utils.rb
151
127
  - lib/asciidoctor-bibtex/extensions.rb
128
+ - lib/asciidoctor-bibtex/path_utils.rb
129
+ - lib/asciidoctor-bibtex/processor.rb
130
+ - lib/asciidoctor-bibtex/string_utils.rb
131
+ - lib/asciidoctor-bibtex/style_utils.rb
152
132
  - lib/asciidoctor-bibtex/version.rb
153
133
  homepage: https://github.com/asciidoctor/asciidoctor-bibtex
154
134
  licenses:
@@ -160,9 +140,9 @@ require_paths:
160
140
  - lib
161
141
  required_ruby_version: !ruby/object:Gem::Requirement
162
142
  requirements:
163
- - - "~>"
143
+ - - ">="
164
144
  - !ruby/object:Gem::Version
165
- version: '2.0'
145
+ version: 2.3.0
166
146
  required_rubygems_version: !ruby/object:Gem::Requirement
167
147
  requirements:
168
148
  - - ">="
@@ -172,5 +152,5 @@ requirements: []
172
152
  rubygems_version: 3.0.3
173
153
  signing_key:
174
154
  specification_version: 4
175
- summary: Adding bibtex functionality to asciidoc
155
+ summary: An Asciidoctor extension that adds bibtex integration to AsciiDoc
176
156
  test_files: []
data/README.md DELETED
@@ -1,104 +0,0 @@
1
- # asciidoctor-bibtex: add bibtex functionality to asciidoc
2
-
3
- asciidoctor-bibtex adds bibtex support for asciidoc documents by introducing
4
- two new macros: `cite:[KEY]` and `bibliography::[]`. Citations are parsed and
5
- replaced with formatted inline texts, and reference lists are automatically
6
- generated and inserted into where `bibliography::[]` is placed.
7
-
8
- asciidoctor-bibtex is designed to be used as an extension to
9
- [asciidoctor](http://asciidoctor.org). Thus this extension can be used
10
- together with other asciidoctor extensions such as
11
- [asciidoctor-mathematical][] and [asciidoctor-pdf][] to enrich your
12
- asciidoc experience. Note that asciidoctor-bibtex no longer support asciidoc-to-asciidoc conversion.
13
-
14
- [asciidoctor-mathematical]: https://github.com/asciidoctor/asciidoctor-mathematical
15
- [asciidoctor-pdf]: https://github.com/asciidoctor/asciidoctor-pdf
16
-
17
- ## History
18
-
19
- asciidoctor-bibtex starts as a fork of [asciidoc-bib][] and goes along a
20
- different way. The major reason for the fork at the time was the differences in
21
- citation and bibliography macros. asciidoc-bib failed to follow the grammar of
22
- macros in asciidoc, thus to avoid breaking existing documents, a fork is
23
- inevitable. Other reasons include the inability to use asciidoctor arguments
24
- in asciidoc-bib.
25
-
26
- While [asciidoc-bib][] focuses on replacing citations in the original
27
- documents and produces new asciidoc documents, asciidoctor-bibtex focuses on
28
- compatibility with asciidoctor and other asciidoctor extensions at the very
29
- beginning. As time passes, asciidoctor-bibtex diverges significantly from its
30
- ancesstor. For example, asciidoctor-bibtex now supports generating real bibtex
31
- citations and bibliography, so it can be used together with
32
- [asciidoctor-latex][] for native bibtex support.
33
-
34
- [asciidoc-bib]: https://github.com/petercrlane/asciidoc-bib
35
- [asciidoctor-latex]: https://github.com/asciidoctor/asciidoctor-latex
36
-
37
- ## Install
38
-
39
- gem install asciidoctor-bibtex
40
-
41
- asciidoctor-bibtex depends on
42
- [bibtex-ruby](http://github.com/inukshuk/bibtex-ruby),
43
- [citeproc-ruby](http://github.com/inukshuk/citeproc-ruby) and
44
- [csl-styles](http://github.com/inukshuk/csl-styles). (Ensure 'ruby-dev' and
45
- 'libxslt1-dev' are installed, so the dependencies will compile.)
46
-
47
- [asciidoctor](https://github.com/asciidoctor/asciidoctor) must also be
48
- installed for 'asciidoctor-bibtex' to work. asciidoctor version 1.5.2 or
49
- higher is required.
50
-
51
- ## Usage
52
-
53
- ### Macros
54
-
55
- Syntax for inserting a citation is the following inline macro:
56
-
57
- cite|citenp:[ref(pages), ...]
58
-
59
- where '(pages)' is optional.
60
-
61
- Examples of "chicago-author-date" style:
62
-
63
- - `cite:[Lane12]` becomes "(Lane 2012)"
64
- - `citenp:[Lane12]` becomes "Lane (2012)"
65
- - `cite:[Lane12(59)]` becomes "(Lane 2012, 59)"
66
-
67
- For *apa* (Harvard-like) style:
68
-
69
- - `cite:[Lane12]` becomes "(Lane, 2012)"
70
- - `citenp:[Lane12]` becomes "Lane (2012)"
71
- - `cite:[Lane12(59)]` becomes "(Lane, 2012, p.59)"
72
-
73
- For *ieee*, a numeric style:
74
-
75
- `cite:[Lane12,Lane11]` becomes "[1, 2]"
76
-
77
- To add a list of formatted references, place `bibliography::[]` on a line by itself.
78
-
79
- ### Document Attributes
80
-
81
- | Attribute Name | Description | Valid Values | Default Value |
82
- | -------------- | --------------- | ---------- | -------------- |
83
- | bibtex-file | Bibtex database file | any string, or empty | Automatic searching |
84
- | bibtex-style | Reference formatting style | any style supported by csl-styles | ieee |
85
- | bibtex-order | Order of citations | `appearance` or `alphabetical` | `appearance` |
86
- | bibtex-format | Formatting of citations and bibliography | `asciidoc`, `bibtex` or `biblatex` | `asciidoc` |
87
- | bibtex-throw | Throw an error on unknown references | `true` or `false` | `false` |
88
-
89
- ### Commandline
90
-
91
- Use asciidoctor-bibtex as an extension:
92
-
93
- ```bash
94
- asciidoctor -r asciidoctor-bibtex sample.adoc
95
- ```
96
-
97
- ## License
98
-
99
- The files within this project may be distributed under the terms of
100
- the Open Works License: http://owl.apotheon.org
101
-
102
- ## Links
103
-
104
- See https://github.com/petercrlane/asciidoc-bib for the original asciidoc-bib.