relaton-render 0.1.0 → 3.0.0.pre.alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -1
  3. data/.github/workflows/release.yml +24 -0
  4. data/.gitignore +14 -0
  5. data/.rubocop.yml +2 -2
  6. data/Gemfile +17 -1
  7. data/README.adoc +61 -197
  8. data/docs/citation-style-pack.adoc +367 -0
  9. data/lib/relaton/render/general.rb +305 -0
  10. data/lib/relaton/render/iso690/element.rb +153 -0
  11. data/lib/relaton/render/iso690/elements/access.rb +44 -0
  12. data/lib/relaton/render/iso690/elements/authorizer.rb +30 -0
  13. data/lib/relaton/render/iso690/elements/citeid.rb +39 -0
  14. data/lib/relaton/render/iso690/elements/component_part.rb +99 -0
  15. data/lib/relaton/render/iso690/elements/creator.rb +258 -0
  16. data/lib/relaton/render/iso690/elements/edition.rb +92 -0
  17. data/lib/relaton/render/iso690/elements/extent.rb +71 -0
  18. data/lib/relaton/render/iso690/elements/identifier.rb +46 -0
  19. data/lib/relaton/render/iso690/elements/location.rb +73 -0
  20. data/lib/relaton/render/iso690/elements/medium.rb +32 -0
  21. data/lib/relaton/render/iso690/elements/numeration.rb +26 -0
  22. data/lib/relaton/render/iso690/elements/production.rb +92 -0
  23. data/lib/relaton/render/iso690/elements/pub_date.rb +56 -0
  24. data/lib/relaton/render/iso690/elements/series.rb +66 -0
  25. data/lib/relaton/render/iso690/elements/size.rb +41 -0
  26. data/lib/relaton/render/iso690/elements/status.rb +30 -0
  27. data/lib/relaton/render/iso690/elements/stddoc.rb +40 -0
  28. data/lib/relaton/render/iso690/elements/title.rb +56 -0
  29. data/lib/relaton/render/iso690/elements/updated.rb +38 -0
  30. data/lib/relaton/render/iso690/elements.rb +67 -0
  31. data/lib/relaton/render/iso690/fields.rb +142 -0
  32. data/lib/relaton/render/iso690/i18n/en.yml +47 -0
  33. data/lib/relaton/render/iso690/i18n/fr.yml +14 -0
  34. data/lib/relaton/render/iso690/i18n/ja.yml +38 -0
  35. data/lib/relaton/render/iso690/i18n.rb +83 -0
  36. data/lib/relaton/render/iso690/identifier_kinds.rb +29 -0
  37. data/lib/relaton/render/iso690/index_renderer.rb +57 -0
  38. data/lib/relaton/render/iso690/kinds.rb +53 -0
  39. data/lib/relaton/render/iso690/renderer.rb +148 -0
  40. data/lib/relaton/render/iso690/style/locale.rb +53 -0
  41. data/lib/relaton/render/iso690/style/name_form.rb +87 -0
  42. data/lib/relaton/render/iso690/style/scheme.rb +33 -0
  43. data/lib/relaton/render/iso690/style/sort_rule.rb +25 -0
  44. data/lib/relaton/render/iso690/style/template_map.rb +40 -0
  45. data/lib/relaton/render/iso690/style/type_template.rb +37 -0
  46. data/lib/relaton/render/iso690/style.rb +119 -0
  47. data/lib/relaton/render/iso690/styles/author-date.yml +31 -0
  48. data/lib/relaton/render/iso690/template.rb +248 -0
  49. data/lib/relaton/render/iso690.rb +26 -0
  50. data/lib/relaton/render/version.rb +5 -0
  51. data/lib/relaton-render.rb +12 -5
  52. data/relaton-render.gemspec +7 -11
  53. metadata +57 -86
  54. data/lib/isodoc/i18n.rb +0 -24
  55. data/lib/isodoc-yaml/i18n-ar.yaml +0 -2
  56. data/lib/isodoc-yaml/i18n-de.yaml +0 -2
  57. data/lib/isodoc-yaml/i18n-en.yaml +0 -22
  58. data/lib/isodoc-yaml/i18n-es.yaml +0 -2
  59. data/lib/isodoc-yaml/i18n-fr.yaml +0 -2
  60. data/lib/isodoc-yaml/i18n-ru.yaml +0 -23
  61. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +0 -2
  62. data/lib/parse/parse.rb +0 -54
  63. data/lib/parse/parse_contributors.rb +0 -96
  64. data/lib/parse/parse_extract.rb +0 -155
  65. data/lib/relaton/config.yml +0 -67
  66. data/lib/relaton/render.rb +0 -123
  67. data/lib/relaton/render_classes.rb +0 -126
  68. data/lib/relaton/render_fields.rb +0 -151
  69. data/lib/relaton/version.rb +0 -5
  70. data/lib/template/template.rb +0 -152
  71. data/lib/utils/utils.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 900cfb8e591fbbd83ee48c2dfa762a317a15c590fb89844b3ce7a759125d4f94
4
- data.tar.gz: 29c15ba8cfe1e2dcfafc8d6a4d9985ed298c4515d4c734e3505dfcca9cb11189
3
+ metadata.gz: ecdbfb0b1c82700b6c957c9eeb259fd48f48d391a35062b07e4d6d6ede4ccb2e
4
+ data.tar.gz: 199330b061ce3e07eb3edff0364ffc313773eb27cf6f7b8d0a216bff4caa3cac
5
5
  SHA512:
6
- metadata.gz: ebd7be4d34144997dcee8593266b75eefca1781341b4f081df290a9df64cbb7d665985c1bd0807c1036b190f68d6877b2bf822281bdc6e7c3a332fce349ac612
7
- data.tar.gz: 8392d3b4d8c836b74cbf7a05435f55b274f24ae1004b247151481a34d86c104818926f3452c68f776a0adb521e9404b908f0d0fde25494014958bfd2c28005ac
6
+ metadata.gz: f21d46a60631252c2011e73096ea2ff321fae8f8f361c9e8bc46b53709d304da350bac73ab3eb44cdf7c5a4ec6a35c74f10875aa5548e417fc9c66afc43a8693
7
+ data.tar.gz: 2fac8549403467928c30917f75e167fba771a3f175c5128d9c2a1daab37cb813cd29b1feb493746559c985df068b68306d9cdd2cd1cb5fb63b82e0e79445a150
@@ -8,8 +8,11 @@ on:
8
8
  tags: [ v* ]
9
9
  pull_request:
10
10
 
11
+ permissions:
12
+ contents: write
13
+
11
14
  jobs:
12
15
  rake:
13
- uses: metanorma/metanorma-build-scripts/.github/workflows/generic-rake.yml@main
16
+ uses: metanorma/ci/.github/workflows/generic-rake.yml@main
14
17
  secrets:
15
18
  pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -0,0 +1,24 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
11
+ Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
12
+ required: true
13
+ default: 'skip'
14
+ repository_dispatch:
15
+ types: [ do-release ]
16
+
17
+ jobs:
18
+ release:
19
+ uses: relaton/support/.github/workflows/release.yml@main
20
+ with:
21
+ next_version: ${{ github.event.inputs.next_version }}
22
+ secrets:
23
+ rubygems-api-key: ${{ secrets.RELATON_CI_RUBYGEMS_API_KEY }}
24
+
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
13
+ .vscode/
14
+ bin/rspec
data/.rubocop.yml CHANGED
@@ -1,10 +1,10 @@
1
1
  # Auto-generated by Cimas: Do not edit it manually!
2
2
  # See https://github.com/metanorma/cimas
3
3
  inherit_from:
4
- - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
5
5
 
6
6
  # local repo-specific modifications
7
7
  # ...
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.5
10
+ TargetRubyVersion: 3.4
data/Gemfile CHANGED
@@ -3,6 +3,22 @@ Encoding.default_internal = Encoding::UTF_8
3
3
 
4
4
  source "https://rubygems.org"
5
5
 
6
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
 
8
8
  gemspec
9
+
10
+ group :development, :test do
11
+ gem "canon"
12
+ gem "relaton", ">= 3.0.0.pre.alpha", "< 4" # the model fixtures; the engine itself is model-agnostic
13
+ gem "debug"
14
+ gem "iso-690-test-suite", github: "relaton/iso-690-test-suite"
15
+ gem "rake", ">= 12.3.3"
16
+ gem "rspec", "~> 3.0"
17
+ gem "simplecov"
18
+ end
19
+
20
+ begin
21
+ eval_gemfile("Gemfile.devel")
22
+ rescue StandardError
23
+ nil
24
+ end
data/README.adoc CHANGED
@@ -1,8 +1,8 @@
1
1
  = Relaton Render
2
2
 
3
- image:https://img.shields.io/gem/v/iso690render.svg["Gem Version", link="https://rubygems.org/gems/iso690render"]
4
- image:https://github.com/metanorma/iso690render/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/iso690render/actions?workflow=rake"]
5
- image:https://codeclimate.com/github/metanorma/iso690render/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/iso690render"]
3
+ image:https://img.shields.io/gem/v/relaton-render.svg["Gem Version", link="https://rubygems.org/gems/relaton-render"]
4
+ image:https://github.com/metanorma/relaton-render/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/relaton-render/actions?workflow=rake"]
5
+ // image:https://codeclimate.com/github/metanorma/relaton-render/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-render"]
6
6
 
7
7
  Gem that takes a https://github.com/relaton/relaton[Relaton] bibliographic description and
8
8
  a configuration, and generates a https://www.metanorma.org[Metanorma] XML rendering of that description.
@@ -13,15 +13,31 @@ a configuration, and generates a https://www.metanorma.org[Metanorma] XML render
13
13
  ----
14
14
  input = "<bibitem type='...'>....</bibitem>"
15
15
 
16
- Relaton::Render::General.new(template: ..., nametemplate: ..., seriestemplate: ..., language: "en", script: "Latn").render(input)
16
+ r = Relaton::Render::General.new(template: ..., nametemplate: ..., seriestemplate: ..., language: "en", script: "Latn")
17
+
18
+ r.render(input) == "Author1 and Author2 2000. Title &c."
19
+
20
+ bibliography = "<references><bibitem id=''>...</bibitem>...<bibitem id=''>...</bibitem></references>"
21
+
22
+ r.render_all(bibliography, type: "author-cite") ==
23
+
24
+ { bibitem["id"] :
25
+ { author: "Author1 and Author2",
26
+ date: "2000a",
27
+ citation: "Author1 and Author2 2000a",
28
+ formattedref: "Author1 and Author2 2000a. Title &c."
29
+ }
30
+ }
17
31
  ----
18
32
 
33
+ The gem processes either Relaton XML, or native Relaton classes.
34
+
19
35
  The gem is intended to be inherited from by Metanorma flavours, which may specialise it with their own
20
36
  code. The templates are however intended to determine much of the rendering.
21
37
 
22
- Gems can provide their configurations in YAML files, and parse them before passing them to the call to Iso690Render.
23
- The built-in values for Iso690Render are given in `/lib/iso690render/config.yml`, and can be overridden by
24
- the parameters of initialising Iso690Render.
38
+ Gems can provide their configurations in YAML files, and parse them before passing them to the call to Relaton::Render.
39
+ The built-in values for Relaton::Render are given in `/lib/relaton/render/general/config.yml`, and can be overridden by
40
+ the parameters of initialising Relaton::Render.
25
41
 
26
42
  The parameters are:
27
43
 
@@ -29,213 +45,61 @@ The parameters are:
29
45
  `script`:: in ISO-15124
30
46
  `template`:: templates for rendering different bibliographic types
31
47
  `nametemplate`:: templates for rendering personal names
48
+ `authorcitetemplate`:: templates for rendering names for the purpose of author-date citations
32
49
  `seriestemplate`:: template for rendering series
33
50
  `journaltemplate`:: template for rendering journals in article citations
34
51
  `extenttemplate`:: templates for rendering extents
35
- `edition_number`:: override formatting of edition number
36
- `edition`:: override formatting of edition
52
+ `sizetemplate`:: templates for rendering sizes
53
+ `edition_ordinal`:: override formatting of edition with ordinal
37
54
  `date`:: default date format (from Twitter CLDR)
55
+ `i18nhash`:: Metanorma internationalisation hash
38
56
 
39
- == Configuration
40
-
41
- === Templates
42
-
43
- There is one template provided for each of the bibliographic types recognised by Relaton (`/bibitem/@type`), and a default template:
44
-
45
- Currently supported:
46
-
47
- * article
48
- * book
49
- * booklet
50
- * manual
51
- * proceedings
52
- * presentation
53
- * thesis
54
- * techreport
55
- * standard
56
- * unpublished
57
- * electronic resource
58
- * inbook
59
- * incollection
60
- * inproceedings
61
- * journal
62
- * website
63
- * webresource
64
- * dataset
65
-
66
- Not currently supported:
67
-
68
- * map
69
- * audiovisual
70
- * film
71
- * video
72
- * broadcast
73
- * software
74
- * graphic_work
75
- * music
76
- * performance
77
- * patent
78
- * archival
79
- * social_media
80
- * alert
81
- * message
82
- * conversation
83
- * misc (default)
84
-
85
-
86
- In Metanorma, not all types are used, but there are exemplars for all of these given on this site, following
87
- the human-readable style used in ISO 690. These can be overridden by supplying corresponding paramerers in the call
88
- to initialise Iso690Render.
89
-
90
- Each `template` is a string marked up with https://shopify.github.io/liquid/[Liquid Markup], with the following fields
91
- drawn from the bibliographic item:
92
-
93
- |===
94
- | Field | Relaton XPath | Multiple | Can come from host | Note
95
-
96
- | title | ./title | | |
97
- | edition | ./edition | | Y | If numeric value, is given internationalised rendering of "nth edition", as set in edition_numbering. Otherwise, the textual content of the tag is given.
98
- | edition_raw | ./edition | | Y | The strict textual content of the tag is given.
99
- | medium | ./medium | | Y |
100
- | place | ./place | | Y |
101
- | publisher | ./contributor[role/@type = 'publisher']/organization/name | | Y |
102
- | distributor | ./contributor[role/@type = 'distributor']/organization/name | | Y |
103
- | standardidentifier | ./docidentifier[not(@type = 'metanorma' or @type = 'ordinal')] | Y | |
104
- | status | ./status | | | Rendering varies by flavour
105
- | uri | ./uri[@type = 'doi' or @type = 'uri' or @type = 'src' or true] | | |
106
- | access_location | ./accessLocation | | Y |
107
- | extent | ./extent | Y | | Render with standard abbreviations for pp, vols, with n-dash, with delimiting of multiple locations
108
- | creatornames | ./contributor[role/@type = 'author'] \| ./contributor[role/@type = 'performer'] \| ./contributor[role/@type = 'adapter'] \| ./contributor[role/@type = 'translator'] \| ./contributor[role/@type = 'editor'] \| ./contributor[role/@type = 'publisher'] \| ./contributor[role/@type = 'distributor'] \| ./contributor | Y | | <<nametemplate,`nametemplate`>> applied to each name; joining template from internationalisation applied to multiple names
109
- | role | ./contributor[role/description] \| ./contributor[role/@type] | | |
110
- | date | ./date[@type = 'issued'] \| ./date[@type = 'circulated'] \| ./date | | Y |
111
- | date_updated | ./date[@type = 'updated'] | | Y |
112
- | date_accessed | ./date[@type = 'accessed'] | | Y |
113
- | series | ./series[@type = 'main' or not(@type) or true] | | Y | <<seriestemplate,`seriestemplate`>> applies to series
114
- | host_creatornames | ./relation[@type = 'includedIn']/ bibitem/contributor[role/@type = 'author'] | | Y | Follows options for `creatornames`
115
- | host_title | ./relation[@type = 'includedIn']/ bibitem/title | Y | Y | Follows options for `creatornames`
116
- | host_role | ./relation[@type = 'includedIn']/ bibitem/contributor[role/description] \| ./relation[@type = 'includedIn']/ bibitem/contributor[role/@type] | | Y |
117
- | type | ./@type | |
118
- | labels | | | text to be looked up in internationalisation configuration files: "edition", "In", "At", "Vol", "Vols", "p.", "pp"
119
- |===
120
-
121
- Many fields are populated either by the description of the bibliographic item itself, or by the description of the item containing it (the _host_ item: `./relation[@type = 'includedIn']/bibitem`). For example, in a paper included in an edited volume, the edition will typically be given for the editor volume, rather than for the paper. Those fields are indicated by "Can come from host" in the table.
122
-
123
- The Liquid template surrounds each field by preceding and following punctuation.
124
-
125
- * Fields are space-delimited. So `<em>{{ title }}</em> [{{medium}}]` are two separate fields.
126
- * If fields are not space-delimited, this is indicated by inserting `|`. So `{{ title }}|{{ medium}}` is two fields, rendered with no space separation.
127
- * If the field is empty, its surrounding markup is also removed. So if there is no medium, then `[{{medium}}]` is not rendered, and the brackets will be stripped.
128
- * Underscore is treated as space, attaching to the preceding or following field. So `,_{{ edition }}_{{ labels['edition'] }}` is treated as the one field.
129
- * If punctuation is space delimited, it is inserted regardless of preceding content. So `{{ creatornames }} ({{date}}) .` will insert the full stop whether or not the date is present.
130
- * Space between punctuation and before punctuation is automatically removed.
131
-
132
- For example:
133
-
134
- ....
135
- "{{ creatornames }} ({{date}}) . <em>{{ title }}</em> [{{medium}}] ,_{{ edition }}_{{ labels['edition'] }} ."
136
- ....
137
-
138
- If a type uses another type's template, the type is mapped to the other type's name; e.g.
139
-
140
- ....
141
- template:
142
- book: ...
143
- booklet: book
144
- ....
145
-
146
- [[nametemplate]]
147
- === Name templates
148
-
149
- The `nametemplate` is a hash of Liquid templates for the formatting of contributor names in particular positions. It
150
- draws on the following fields drawn from the bibliographic item:
151
-
152
- |===
153
- | Field | Relaton XPath | Multiple | Note
154
-
155
- | surname[0] | ./contributor[1]/person/name/surname \| ./contributor[1]/person/name/completename \| ./contributor[1]/organization/name | | i.e. surname is the name default
156
- | surname[1] | ./contributor[2]/name/surname | |
157
- | surname[2] | ./contributor[3]/name/surname | |
158
- | initials[0] | ./contributor[1]/name/initial | | If not supplied, the first letter of each given name is used instead
159
- | initials[1] | ./contributor[2]/name/initial | |
160
- | given[0] | ./contributor[1]/name/forename[1] | | If not supplied, initials are used instead
161
- | given[1] | ./contributor[2]/name/forename[1] | |
162
- | middle[0] | ./contributor[1]/name/forename[not(first())] | Y |
163
- | middle[1] | ./contributor[2]/name/forename[not(first())] | Y |
164
- |===
165
-
166
- There are at least three distinct `nametemplate` instances that need to be provided, one for a single contributor (`one:`), one for two contributors (`two:`), one for three or more (`more:`), and optionally one for "et al." (`etal:`). The number of contributors for which "et al." starts being used is indicated by `etal_count`.
167
-
168
- For example:
169
- ....
170
- {
171
- one: "{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }}",
172
- two: "{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }} &amp; {{ given[1] }} {{ middle[1] | slice : 0 }} {{ surname[1] }}",
173
- more: "{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }}, {{ given[1] }} {{ middle[1] | slice : 0 }} {{ surname[1] }} &amp; {{ given[2] }} {{ middle[2] | slice : 0 }} {{ surname[2] }}",
174
- etal: "{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }}, {{ given[1] }} {{ middle[1] | slice : 0 }} {{ surname[1] }} <em>et al.</em>",
175
- etal_count: 6
176
- }
177
- ....
178
-
179
- In the case of `more`, the `(name)[1]` entries are repeated for all additional authors above 2 and before the final author.
180
-
181
- [[seriestemplate]]
182
- === Series template
183
-
184
- The `seriestemplate` is a template for the rendering of series information. It draws on the following fields drawn from the bibliographic item:
185
-
186
- |===
187
- | Field | Relaton XPath | Multiple | Can come from host | Note
188
-
189
- | series_title | ./series[@type = 'main' or not(@type) or true]/name | | Y |
190
- | series_abbr | ./series[@type = 'main' or not(@type) or true]/abbreviation | | Y |
191
- | series_num | ./series[@type = 'main' or not(@type) or true]/number | | Y |
192
- | series_partnumber | ./series[@type = 'main' or not(@type) or true]/partnumber | | Y |
193
- | series_run | ./series[@type = 'main' or not(@type) or true]/run | | Y |
194
- |===
57
+ == Functionality
195
58
 
196
- For example: `{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %} ,_({{series_run}}) {{series_num}}|({{series_partnumber}})`
59
+ === Rendering single reference
197
60
 
198
- === Journal template
61
+ Given an Relaton bibitem object (or equivalent Relaton XML), `render(input)` will output a formatted reference for that
62
+ bibitem, following the rules laid out in the configuration. That output can be inserted into the `<formattedref>` element
63
+ of the bibitem by the calling code, and used as the authoritative rendering of the citation.
199
64
 
200
- The `journaltemplate` is a template for the rendering of series information, when they relate to articles in a journal. The template is distinct because of longstanding practice of rendering journal information differently from monograph series information. The template draws on the same fields as the `seriestemplate`, but because the journal title is typically italicised and the numeration is not, any italicisation needs to occur within the template.
65
+ This method does not address how the bibliographic item is to be cited, and does not differentiate citations with the same
66
+ author and date. It should not be used for rendering of references aligned to the author-date citation system.
201
67
 
202
- For example, the recommended practice in the current edition of ISO 690 is to give explicit volume labels:
68
+ === Rendering multiple references
203
69
 
204
- `<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> {{ labels['volume'] }}_{{series_num}} {{ labels['part'] }}_{{series_partnumber}}`
70
+ Given a collection of Relaton bibitem objects (or equivalent Relaton XML, wrapped in `<references>`),
71
+ `render_all(bibliography, type: type)`
72
+ will output a hash of objects, with information to be used both for rendering references, and for generating citations.
73
+ This method addresses the disambiguation of citations, and changes to rendering of references reflecting that disambiguation
74
+ (e.g. differentiating two works with the same wuthor surname and year: _Jones 1996a_ and _Jones 1996b_).
75
+ For that reason, this method should be used for references using the author-date citation system.
205
76
 
206
- A common template that drops those labels is:
77
+ The `type` argument of `render_all` reflects the citation system to be used.
207
78
 
208
- `<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> {{series_num}}|({{series_partnumber}})`
79
+ * If it is set to "author-date", citations with the same author and date will be disambiguated from each other
80
+ by appending a letter to the date, in the order in which they occur in `bibliography`. (That means that any fixed sorting
81
+ of references needs to be applied before the bibliography is presented to the method.)
82
+ * If it is set to nil (as is the default), no such disambiguation occurs.
209
83
 
210
- === Extent template
84
+ The hash maps from the anchor of each bibitem (`bibitem/@id`), to an object containing the following fields:
211
85
 
212
- The extent of a reference can be expressed differently depending on the type of bibliographic item. For example, the extent of a book is its page count, and is typically expressed as something like _59 pp._ On the other hand, the extent of an article is expressed as _pp. 9–20_, or just _9–20_.
86
+ `formattedref`:: the formatted reference, as output by `render(input)`, but with the date of the citation disambiguated
87
+ if called with `type: "author-date"`.
88
+ `citation`:: the citation for the reference (Author-Date if called with `type: "author-date"`; `docidentifier` if called with `type: nil`).
89
+ `author`:: the author designation for the reference (if called with `type: "author-date"`)
90
+ `date`:: the date designation for the reference, with disambiguating letter if necessary (if called with `type: "author-date"`).
91
+ The author and date are differentiated so that consumers can separate them in citations -- e.g. "Jones (1996) claims",
92
+ "(Jones 1996, 1997)".
213
93
 
214
- To capture this, a separate template is supplied under `extenttemplate` for each bibliographic item type. For those types where none is supplied, the template given for `misc` is used as the default.
94
+ === Parsing single reference
215
95
 
216
- The template draws on the defined types of locality of extents; the most common of these is `page` and `volume`. Locality types are the fields used in the Liquid templates; for example:
96
+ Given an Relaton bibitem object (or equivalent Relaton XML), `parse(input)` will output the hash of fields that is passed into the
97
+ Liquid templates described below for rendering: it is the hash of bibliographic fields extracted by the gem.
217
98
 
218
- ....
219
- {
220
- book: "{{ volume }}_{{ label['extent']['volume'] }}, {{ page }}_{{ label['extent']['page'] }}"
221
- inbook: "{{ volume }}: {{ page }}"
222
- misc: "{{ label['extent']['volume'] }}_{{ volume }}, {{ label['extent']['page'] }}_{{ page }}"
223
- }
224
- ....
225
-
226
- The internationalisation files define a singular and a plural version of the locality types, under `labels['extent']`
227
-
228
- * The plural is always used if the extent is a range (with a `<from>` and `<to>`).
229
- * In a host type of bibliographic item, the extent is singular only if the value is `1`, else it is plural (_1 p._, _2 pp._)
230
- * In an included item (`inbook`, `incollection`, `inproceedings`, `article`, or any item with an `includedIn` relation),
231
- the singular is used if the extent is not a range (_pp. 2–4_ vs. _p. 3_)..
99
+ == Configuration
232
100
 
233
- === Other
101
+ For the configuation YAML used in relaton-render, refer to https://relaton.org/specs/relaton-render
234
102
 
235
- In addition, the configuration includes different configuration options for rendering:
103
+ == Documentation
236
104
 
237
- The internationalisation file sets the following variables, which can be overridden in configuration parameters:
238
- `edition_number`:: has following values corresponding to the rule-based number rules defined in https://github.com/twitter/twitter-cldr-rb[Twitter CLDR]
239
- for a language. For example, English _4th_ is defined as `["OrdinalRules", "digits-ordinal"]`, because under twitter-cldr, `4th` is generated as `4.localize(:en).to_rbnf_s("OrdinalRules", "digits-ordinal")`.
240
- `edition`:: is the localised expression for edition, with the edition number given as %. So _4th ed.` is generated with `edition` as `% ed.`.
241
- `date`:: date format default, taken from https://github.com/twitter/twitter-cldr-rb[Twitter CLDR]: `to_full_s`, `to_long_s`, `to_medium_s`, `to_short_s`, or one of the `to_additional_s` formats. One value is given for each of "month_year", "day_month_year", and "date_time"; e.g. `{ month_year: to_long_s, day_month_year: to_long_s, date_time: to_long_s }`.
105
+ * link:docs/citation-style-pack.adoc[Defining a Citation Style: the pack format] — the authoritative spec for CitationStyle YAML packs: resource types, presentation patterns, model presentation templates, locale/punctuation, inheritance and conformance.