relaton-render 0.7.9 → 0.8.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 -296
- data/lib/relaton/render/template/template.rb +34 -1
- data/lib/relaton/render/version.rb +1 -1
- data/lib/relaton-render.rb +2 -1
- data/relaton-render.gemspec +3 -1
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d810e39f814202710d6ea0e7ca8aca20e3a97f7e676fdf6dd09626c31ed13a
|
4
|
+
data.tar.gz: b506d8892fa722266c574023ea7c53293f1eafc592220f0352c9ef1aa914d1c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a39489da1654f88d4e5224cb38e79219a7b59299974fa3813d3487c4488e14b10a113ab024dc773d70d257441906008e46f0c607979cb637c6e1c362c5d0708
|
7
|
+
data.tar.gz: 00adc59eb9ff7e8355f2d4400e691c5b47c82668429126fe810fa3104b9595cf619068f591e3fd28c25b0cc674320217a010b776ba88102072b3312f9c92560c
|
data/README.adoc
CHANGED
@@ -35,9 +35,9 @@ The gem processes either Relaton XML, or native Relaton classes.
|
|
35
35
|
The gem is intended to be inherited from by Metanorma flavours, which may specialise it with their own
|
36
36
|
code. The templates are however intended to determine much of the rendering.
|
37
37
|
|
38
|
-
Gems can provide their configurations in YAML files, and parse them before passing them to the call to
|
39
|
-
The built-in values for
|
40
|
-
the parameters of initialising
|
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.
|
41
41
|
|
42
42
|
The parameters are:
|
43
43
|
|
@@ -70,7 +70,8 @@ author and date. It should not be used for rendering of references aligned to th
|
|
70
70
|
Given a collection of Relaton bibitem objects (or equivalent Relaton XML, wrapped in `<references>`),
|
71
71
|
`render_all(bibliography, type: type)`
|
72
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
|
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_).
|
74
75
|
For that reason, this method should be used for references using the author-date citation system.
|
75
76
|
|
76
77
|
The `type` argument of `render_all` reflects the citation system to be used.
|
@@ -97,296 +98,5 @@ Liquid templates described below for rendering: it is the hash of bibliographic
|
|
97
98
|
|
98
99
|
== Configuration
|
99
100
|
|
100
|
-
|
101
|
+
For the configuation YAML used in relaton-render, refer to https://relaton.org/specs/relaton-render
|
101
102
|
|
102
|
-
There is one template provided for each of the bibliographic types recognised by Relaton (`/bibitem/@type`), and a default template:
|
103
|
-
|
104
|
-
Currently supported:
|
105
|
-
|
106
|
-
* article
|
107
|
-
* book
|
108
|
-
* booklet
|
109
|
-
* manual
|
110
|
-
* proceedings
|
111
|
-
* presentation
|
112
|
-
* thesis
|
113
|
-
* techreport
|
114
|
-
* standard
|
115
|
-
* unpublished
|
116
|
-
* electronic resource
|
117
|
-
* inbook
|
118
|
-
* incollection
|
119
|
-
* inproceedings
|
120
|
-
* journal
|
121
|
-
* website
|
122
|
-
* webresource
|
123
|
-
* dataset
|
124
|
-
|
125
|
-
Not currently supported:
|
126
|
-
|
127
|
-
* map
|
128
|
-
* audiovisual
|
129
|
-
* film
|
130
|
-
* video
|
131
|
-
* broadcast
|
132
|
-
* software
|
133
|
-
* graphic_work
|
134
|
-
* music
|
135
|
-
* performance
|
136
|
-
* patent
|
137
|
-
* archival
|
138
|
-
* social_media
|
139
|
-
* alert
|
140
|
-
* message
|
141
|
-
* conversation
|
142
|
-
* misc (default)
|
143
|
-
|
144
|
-
|
145
|
-
In Metanorma, not all types are used, but there are exemplars for all of these given on this site, following
|
146
|
-
the human-readable style used in ISO 690. These can be overridden by supplying corresponding paramerers in the call
|
147
|
-
to initialise Iso690Render.
|
148
|
-
|
149
|
-
Each `template` is a string marked up with https://shopify.github.io/liquid/[Liquid Markup], with the following fields
|
150
|
-
drawn from the bibliographic item:
|
151
|
-
|
152
|
-
|===
|
153
|
-
| Field | Relaton XPath | Multiple | Can come from host | Note
|
154
|
-
|
155
|
-
| title | ./title | | | If multiples, prioritise language match
|
156
|
-
| 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.
|
157
|
-
| edition_raw | ./edition | | Y | The strict textual content of the tag is given.
|
158
|
-
| edition_num | ./edition[@number] | | Y |
|
159
|
-
| medium | ./medium | | Y |
|
160
|
-
| place | ./place | | Y |
|
161
|
-
| publisher | ./contributor[role/@type = 'publisher']/organization/name | | Y |
|
162
|
-
| distributor | ./contributor[role/@type = 'distributor']/organization/name | | Y |
|
163
|
-
| authorizer | ./contributor[role/@type = 'authorizer']/organization/name \| ./contributor[role/@type = 'publisher']/organization/name | | Y |
|
164
|
-
| authoritative_identifier | ./docidentifier[not(@type = 'metanorma' or @type = 'ordinal' or @type = 'ISBN' or @type = 'ISSN' or @type = 'DOI')] | Y | |
|
165
|
-
| other_identifier | ./docidentifier[@type = 'ISBN' or @type = 'ISSN' or @type = 'DOI'] | Y | | By default, each such identifier is prefixed with its type and colon
|
166
|
-
| doi | ./docidentifier[@type = 'DOI'] | Y | | No prefix supplied
|
167
|
-
| status | ./status | | | Rendering varies by flavour
|
168
|
-
| uri | ./uri[@type = 'citation' or @type = 'uri' or @type = 'src' or true] | | | If multiples, prioritise language match. Always exclude DOI: that is not where the resource is available from
|
169
|
-
| access_location | ./accessLocation | | Y |
|
170
|
-
| extent | ./extent | Y | | Render with standard abbreviations for pp, vols, with n-dash, with delimiting of multiple locations
|
171
|
-
| creatornames | ./contributor[role/@type = 'author'] \| ./contributor[role/@type = 'performer'] \| ./contributor[role/@type = 'adapter'] \| ./contributor[role/@type = 'translator'] \| ./contributor[role/@type = 'editor'] \| ./contributor[role/@type = 'distributor'] \| ./contributor[role/@type = 'authorizer'] \| ./contributor | Y | | <<nametemplate,`nametemplate`>> applied to each name; joining template from internationalisation applied to multiple names
|
172
|
-
| authorcite | ./contributor[role/@type = 'author'] \| ./contributor[role/@type = 'performer'] \| ./contributor[role/@type = 'adapter'] \| ./contributor[role/@type = 'translator'] \| ./contributor[role/@type = 'editor'] \| ./contributor[role/@type = 'distributor'] \| ./contributor[role/@type = 'authorizer'] \| ./contributor | Y | | <<authorcitetemplate,`authorcitetemplate`>> applied to each name; joining template from internationalisation applied to multiple names
|
173
|
-
| role | ./contributor[role/description] \| ./contributor[role/@type] | | |
|
174
|
-
| date | ./date[@type = 'issued'] \| ./date[@type = 'circulated'] \| ./date | | Y | Always truncated to just year
|
175
|
-
| date_updated | ./date[@type = 'updated'] | | Y |
|
176
|
-
| date_accessed | ./date[@type = 'accessed'] | | Y |
|
177
|
-
| series | ./series[@type = 'main' or not(@type) or true] | | Y | <<seriestemplate,`seriestemplate`>> applies to series
|
178
|
-
| host_creatornames | ./relation[@type = 'includedIn']/ bibitem/contributor[role/@type = 'author'] | | Y | Follows options for `creatornames`
|
179
|
-
| host_title | ./relation[@type = 'includedIn']/ bibitem/title | Y | Y | Follows options for `creatornames`
|
180
|
-
| host_role | ./relation[@type = 'includedIn']/ bibitem/contributor[role/description] \| ./relation[@type = 'includedIn']/ bibitem/contributor[role/@type] | | Y |
|
181
|
-
| type | ./@type | |
|
182
|
-
| labels | | | text to be looked up in internationalisation configuration files: "edition", "In", "At", "Vol", "Vols", "p.", "pp"
|
183
|
-
|===
|
184
|
-
|
185
|
-
Missing dates and places of publication are rendered as "n.d." and "n.p." or the equivalent internationalisation (`no_date`, `no_place` in the internationalisation YAML files.) However, missing dates are left as nil in standards, as undated standards indicate that the citation applies to the latest version of the standard, and not that the date is unknown. Missing dates are also left as nil in webresources and websites, since they are continuously updated.
|
186
|
-
|
187
|
-
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.
|
188
|
-
|
189
|
-
The Liquid templates use the filters defined in Liquid, such as `upcase`. We have defined some custom filters:
|
190
|
-
|
191
|
-
* `capitalize_first` capitalises only the first word in a string, and does not lowercase other words in the string. So "third edition" becomes "Third edition", but "3. Aufl." does not become "3. aufl."
|
192
|
-
|
193
|
-
The Liquid template surrounds each field by preceding and following punctuation.
|
194
|
-
|
195
|
-
* Fields are space-delimited. So `<em>{{ title }}</em> [{{medium}}]` are two separate fields.
|
196
|
-
* If fields are not space-delimited, this is indicated by inserting `|`. So `{{ title }}|{{ medium}}` is two fields, rendered with no space separation.
|
197
|
-
* 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.
|
198
|
-
* Underscore is treated as space, attaching to the preceding or following field. So `,_{{ edition }}_{{ labels['edition'] }}` is treated as the one field.
|
199
|
-
* Underscore is escaped by \. So `<span_class="std\_note">` maps to `<span class="std_note">`.
|
200
|
-
* 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.
|
201
|
-
* Space between punctuation and before punctuation is automatically removed.
|
202
|
-
* Spaces within fields are globally converted to underscores. For that reason, any filter operations in Liquid need to refer to underscore instead of space.
|
203
|
-
* There are primary and secondary quotation marks defined as labels, and subject to internationalisation: `{{ labels['qq-open'] }}`, `{{ labels['qq-close'] }}`, `{{ labels['q-open'] }}`, `{{ labels['q-close'] }}`. By default in Latn and Cyrl, these are `<em>`/`</em>` and empty, respectively; they are 《…》 , 〈…〉 in Hans, and wavy underline, empty in Hant. If these are used, they need not to be space-delimited from what they quote; e.g. `{{ labels['qq-open'] }}{{ title }}{{ labels['qq-close'] }}`.
|
204
|
-
|
205
|
-
For example:
|
206
|
-
|
207
|
-
....
|
208
|
-
"{{ creatornames }} ({{date}}) . <em>{{ title }}</em> [{{medium}}] ,_{{ edition }}_{{ labels['edition'] }} ."
|
209
|
-
....
|
210
|
-
|
211
|
-
If a type uses another type's template, the type is mapped to the other type's name; e.g.
|
212
|
-
|
213
|
-
....
|
214
|
-
template:
|
215
|
-
book: ...
|
216
|
-
booklet: book
|
217
|
-
....
|
218
|
-
|
219
|
-
[[nametemplate]]
|
220
|
-
=== Name templates
|
221
|
-
|
222
|
-
The `nametemplate` is a hash of Liquid templates for the formatting of contributor names in particular positions. It
|
223
|
-
draws on the following fields drawn from the bibliographic item:
|
224
|
-
|
225
|
-
|===
|
226
|
-
| Field | Relaton XPath | Multiple | Note
|
227
|
-
|
228
|
-
| surname[0] | ./contributor[1]/person/name/surname \| ./contributor[1]/person/name/completename | | i.e. surname is the name default
|
229
|
-
| surname[1] | ./contributor[2]/name/surname | |
|
230
|
-
| surname[2] | ./contributor[3]/name/surname | |
|
231
|
-
| initials[0] | ./contributor[1]/name/formatted-initials \| ./contributor[1]/name/forename/@initial | | If not supplied, the first letter of each given name is used instead
|
232
|
-
| initials[1] | ./contributor[2]/name/initial | |
|
233
|
-
| given[0] | ./contributor[1]/name/forename[1] | | If not supplied, initials are used instead
|
234
|
-
| given[1] | ./contributor[2]/name/forename[1] | |
|
235
|
-
| middle[0] | ./contributor[1]/name/forename[not(first())] | Y |
|
236
|
-
| middle[1] | ./contributor[2]/name/forename[not(first())] | Y |
|
237
|
-
| nonpersonal[0] |./contributor[1]/organization/name | Y |
|
238
|
-
| nonpersonal[1] |./contributor[2]/organization/name | Y |
|
239
|
-
|===
|
240
|
-
|
241
|
-
The `formatted-initials` field is presumed to contain full stops, and so do the surrogates of that
|
242
|
-
field done by using individual forenames' `initial` attributes, or the forename initials.
|
243
|
-
Initials are considered delimited by a full stop followed by space or an alphabetic character.
|
244
|
-
If the full stops are to be stripped, as is often required by bibliographic styles, that needs to occur within the
|
245
|
-
Liquid template. Bibliographic styles also govern whether initials are separated by space; this gem treats full stop,
|
246
|
-
not space, as the initials delimiter.
|
247
|
-
|
248
|
-
(So _D. X._ is two initials, as is _D.X._, but _M.-J._ is a single initial, and so is _de S._)
|
249
|
-
|
250
|
-
|
251
|
-
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`.
|
252
|
-
|
253
|
-
For example:
|
254
|
-
....
|
255
|
-
{
|
256
|
-
one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }}{% endif %}",
|
257
|
-
two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }}{% endif %} & {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{ given[1] }} {{ middle[1] | slice : 0 }} {{ surname[1] }}{% endif %}",
|
258
|
-
more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{ given[1] }} {{ middle[1] | slice : 0 }} {{ surname[1] }}{% endif %} & {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{ given[2] }} {{ middle[2] | slice : 0 }} {{ surname[2] }}{% endif %}",
|
259
|
-
etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{ surname[0] }}, {{ given[0] }} {{ middle[0] | slice : 0 }}{% endif %}, {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{ given[1] }} {{ middle[1] | slice : 0 }} {{ surname[1] }}{% endif %} <em>et al.</em>",
|
260
|
-
etal_count: 6
|
261
|
-
}
|
262
|
-
....
|
263
|
-
|
264
|
-
In the case of `more`, the `(name)[1]` entries are repeated for all additional authors above 2 and before the final author.
|
265
|
-
|
266
|
-
The behaviour of _et al._ can be specified as follows:
|
267
|
-
|
268
|
-
* `etal_count`: the number of authors to trigger _et al._ in bibliographic rendering
|
269
|
-
* `etal_display`: how many authors to show if using _et al._ in bibliography (by default, same as `etal_count`)
|
270
|
-
|
271
|
-
So the Chicago Manual of Style behaviour:
|
272
|
-
|
273
|
-
____
|
274
|
-
For more than ten authors (not shown here), list the first seven in the reference list, followed by et al.
|
275
|
-
____
|
276
|
-
|
277
|
-
is realised with etal_count = 10, etal_display = 7
|
278
|
-
|
279
|
-
[[authorcitetemplate]]
|
280
|
-
=== Author citation templates
|
281
|
-
|
282
|
-
The `authorcitetemplate` is a subclass of the name template, configured for rendering author names for author-date citations.
|
283
|
-
That means that it typically selects only surnames for rendering.
|
284
|
-
|
285
|
-
|
286
|
-
The behaviour of _et al._ in author-date citations can be specified as follows:
|
287
|
-
|
288
|
-
* `etal_count`: the number of authors to trigger _et al._ in bibliographic rendering
|
289
|
-
* `etal_display`: how many authors to show if using _et al._ in bibliography (by default, same as `etal_count`)
|
290
|
-
|
291
|
-
[[seriestemplate]]
|
292
|
-
=== Series template
|
293
|
-
|
294
|
-
The `seriestemplate` is a template for the rendering of series information. It draws on the following fields drawn from the bibliographic item:
|
295
|
-
|
296
|
-
|===
|
297
|
-
| Field | Relaton XPath | Multiple | Can come from host | Note
|
298
|
-
|
299
|
-
| series_title | ./series[@type = 'main' or not(@type) or true]/name | | Y |
|
300
|
-
| series_abbr | ./series[@type = 'main' or not(@type) or true]/abbreviation | | Y |
|
301
|
-
| series_num | ./series[@type = 'main' or not(@type) or true]/number | | Y |
|
302
|
-
| series_partnumber | ./series[@type = 'main' or not(@type) or true]/partnumber | | Y |
|
303
|
-
| series_run | ./series[@type = 'main' or not(@type) or true]/run | | Y |
|
304
|
-
| series_place | ./series[@type = 'main' or not(@type) or true]/place | | Y |
|
305
|
-
| series_organization | ./series[@type = 'main' or not(@type) or true]/organization | | Y |
|
306
|
-
| series_dates | ./series[@type = 'main' or not(@type) or true]/from, ./series[@type = 'main' or not(@type) or true]/to | | Y |
|
307
|
-
|===
|
308
|
-
|
309
|
-
For example: `{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %} ,_({{series_run}}) {{series_num}}|({{series_partnumber}})`
|
310
|
-
|
311
|
-
=== Journal template
|
312
|
-
|
313
|
-
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.
|
314
|
-
|
315
|
-
For example, the recommended practice in the current edition of ISO 690 is to give explicit volume labels:
|
316
|
-
|
317
|
-
`<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> {{ labels['volume'] }}_{{series_num}} {{ labels['part'] }}_{{series_partnumber}}`
|
318
|
-
|
319
|
-
A common template that drops those labels is:
|
320
|
-
|
321
|
-
`<em>{% if series_abbr %}{{series_abbr}}{% else %}{{series_title}}{% endif %}</em> {{series_num}}|({{series_partnumber}})`
|
322
|
-
|
323
|
-
=== Extent template
|
324
|
-
|
325
|
-
The extent of a bibliographic item may be expressed differently depending on the type of bibliographic item. For example, the extent of a book chapter may be expressed as _pp. 9–20_, while the extent of an article may be expressed as just _9–20_.
|
326
|
-
|
327
|
-
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.
|
328
|
-
|
329
|
-
The template draws on the defined types of locality of extents; the most common of these is `volume`, `issue` (within volume; "number" for journals), and `page`. Locality types are the fields used in the Liquid templates; for example:
|
330
|
-
|
331
|
-
....
|
332
|
-
{
|
333
|
-
article: "{{ volume_raw }}|({{ issue_raw }}) : {{ page_raw }}"
|
334
|
-
misc: "{{ volume }}, {{ page }}"
|
335
|
-
}
|
336
|
-
....
|
337
|
-
|
338
|
-
The internationalisation files define a singular and a plural version of the locality types, under `labels['extent']`.
|
339
|
-
|
340
|
-
* The plural label is always used if the extent is a range (with a `<from>` and `<to>`).
|
341
|
-
* The singular label is used if the extent is not a range (_pp. 2–4_ vs. _p. 3_).
|
342
|
-
* The internationalisation files include a slot where the number or number range is inserted, indicated by `%`, since this varies by language. (For instance, English has `pp. %`, whereas Chinese has `第%页`.)
|
343
|
-
* The number of the volume, issue/number, or page, without accompanying labels, is given in `volume_raw`, `issue_raw`, and `page_raw`.
|
344
|
-
|
345
|
-
=== Size template
|
346
|
-
|
347
|
-
The size of a bibliographic item is distinct from the extent: the size is how large the item is (e.g. how many pages are in the book), whereas the extent is how much of the host item the item covers (e.g. which pages of the book are in the current chapter.) They can be displayed quite differently from extent; for example, while extent pages is given in English as _pp. 9–20_ or _p. 3_, size pages is given as _3 pp._.
|
348
|
-
|
349
|
-
To capture this, a separate template is supplied under `sizetemplate` for each bibliographic item type. Again, for those types where none is supplied, the template given for `misc` is used as the default.
|
350
|
-
|
351
|
-
The template draws on the defined types of locality of extents; the following are currently recognised:
|
352
|
-
|
353
|
-
|===
|
354
|
-
| Field | Relaton XPath | Note
|
355
|
-
|
356
|
-
| volume | ./medium/size[@type = 'volume'] | With internationalisation of label
|
357
|
-
| volume_raw | ./medium/size[@type = 'volume'] |
|
358
|
-
| issue | ./medium/size[@type = 'issue'] | With internationalisation of label
|
359
|
-
| issue_raw | ./medium/size[@type = 'issue'] |
|
360
|
-
| page | ./medium/size[@type = 'page'] | With internationalisation of label
|
361
|
-
| page_raw | ./medium/size[@type = 'page'] |
|
362
|
-
| data | ./medium/size[@type = 'data'] | Unit of size is included in value
|
363
|
-
| duration | ./medium/size[@type = 'time'] | Expressed in ISO 8601 duration
|
364
|
-
|===
|
365
|
-
|
366
|
-
|
367
|
-
Locality types are the fields used in the Liquid templates; for example:
|
368
|
-
|
369
|
-
....
|
370
|
-
{
|
371
|
-
dataset: "{{ data }}"
|
372
|
-
misc: "{{ volume }}, {{ page }}, {{ data }}, {{ duration }}"
|
373
|
-
}
|
374
|
-
....
|
375
|
-
|
376
|
-
The internationalisation files define a singular and a plural version of the locality types, under `labels['size']`.
|
377
|
-
|
378
|
-
* The plural label is always used if the extent is a range (with a `<from>` and `<to>`).
|
379
|
-
* The label is singular only if the value is `1`, else it is plural (_1 p._, _2 pp._)
|
380
|
-
* Again, the internationalisation files include a slot where the number or number range is inserted, since this varies by language.
|
381
|
-
* The number of volumes or pages, without accompanying labels, is given in `volume_raw` and `page_raw`.
|
382
|
-
* Multiple spans of the same type are joined by `+`; e.g. _xlii + 76 pp._.
|
383
|
-
|
384
|
-
=== Other
|
385
|
-
|
386
|
-
In addition, the configuration includes different configuration options for rendering:
|
387
|
-
|
388
|
-
The internationalisation file sets the following variables, which can be overridden in configuration parameters:
|
389
|
-
`edition_number`:: has following values corresponding to the rule-based number rules defined in https://github.com/twitter/twitter-cldr-rb[Twitter CLDR].
|
390
|
-
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")`. If missing, the raw number is given.
|
391
|
-
`edition`:: is the localised expression for edition, with the edition number given as %. So _4th ed.` is generated with `edition` as `% ed.`.
|
392
|
-
`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 }`.
|
@@ -1,14 +1,39 @@
|
|
1
1
|
require_relative "../utils/utils"
|
2
2
|
require_relative "liquid"
|
3
|
+
require "singleton"
|
3
4
|
|
4
5
|
module Relaton
|
5
6
|
module Render
|
6
7
|
module Template
|
8
|
+
class CacheManager
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
attr_accessor :mutex
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@cache = {}
|
15
|
+
@mutex = Mutex.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def store(key, value)
|
19
|
+
@cache[key] = value
|
20
|
+
end
|
21
|
+
|
22
|
+
def retrieve(key)
|
23
|
+
@cache[key]
|
24
|
+
end
|
25
|
+
|
26
|
+
def clear
|
27
|
+
@cache.clear
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
7
31
|
class General
|
8
32
|
attr_reader :template_raw
|
9
33
|
|
10
34
|
def initialize(opt = {})
|
11
35
|
@htmlentities = HTMLEntities.new
|
36
|
+
@templatecache = CacheManager.instance
|
12
37
|
customise_liquid
|
13
38
|
parse_options(opt)
|
14
39
|
end
|
@@ -52,7 +77,15 @@ module Relaton
|
|
52
77
|
|
53
78
|
def template_process(template)
|
54
79
|
template.is_a?(String) or return template
|
55
|
-
|
80
|
+
t = nil
|
81
|
+
@templatecache.mutex.synchronize do
|
82
|
+
unless t = @templatecache.retrieve(template)
|
83
|
+
t = ::Liquid::Template
|
84
|
+
.parse(add_field_delim_to_template(template))
|
85
|
+
@templatecache.store(template, t)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
t
|
56
89
|
end
|
57
90
|
|
58
91
|
def add_field_delim_to_template(template)
|
data/lib/relaton-render.rb
CHANGED
data/relaton-render.gemspec
CHANGED
@@ -28,11 +28,13 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
spec.add_development_dependency "simplecov"
|
30
30
|
|
31
|
-
spec.add_dependency "isodoc-i18n", "~> 1.
|
31
|
+
spec.add_dependency "isodoc-i18n", "~> 1.3.0"
|
32
32
|
spec.add_dependency "liquid", "~> 5"
|
33
33
|
spec.add_dependency "nokogiri"
|
34
34
|
spec.add_dependency "relaton-bib", ">= 1.13.0"
|
35
35
|
spec.add_dependency "twitter_cldr"
|
36
36
|
spec.add_dependency "tzinfo-data" # we need this for windows only
|
37
|
+
spec.add_dependency "base64" # Liquid
|
38
|
+
spec.add_dependency "bigdecimal" # Liquid
|
37
39
|
#spec.metadata["rubygems_mfa_required"] = "true"
|
38
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.3.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.3.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: liquid
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,34 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: base64
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: bigdecimal
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
181
209
|
description: Rendering of ISO 690 XML
|
182
210
|
email:
|
183
211
|
- open.source@ribose.com
|