relaton-render 0.3.3 → 0.3.5.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4af2a199386cc0a95ba9f02a2ba08f5ba146783acfc3c8eb0fb420e50c29bc70
4
- data.tar.gz: b6d8e184fd3cd9709bfb3836613a38d43f0959d26f8c9f23316df31633870252
3
+ metadata.gz: 463f69ee3cd8df231fa7b558afa3fdff0213a04619b9141ffd58d145ba9ad799
4
+ data.tar.gz: be68264b538433ac5ff334c18c19557743b3aeba46e773943ee93bcb11233d13
5
5
  SHA512:
6
- metadata.gz: 7edf0a562d388abfb02883976c40155d7c92aeb9563f06d16ee1fda8da0c63ad88094af034562a61fa0aa1ebf798842d04c8f357cc62eb64cd370ef94db8d1ca
7
- data.tar.gz: 41e86886b6d865301f98b86d1aa95c8cb9ced5da5db42c3cd2bc35697242b9fb0f007e1bd1ee5a1531230a13a162c70e4371ed060abbd12aa53c03eb0b23dff7
6
+ metadata.gz: f2e68aa2f72a5afa9668bf2855a058bcc9d82b67648bcfc35bbe665e9894eea4b30d74c060dad833849c4236604efb24436fdf42f3f4683c2ef187807945a903
7
+ data.tar.gz: b9371ae7c68ab965722c9a5b11fb569828deb2a8a113853ab7c54aef09025d9eecd8097aa0cfdaf52216f8bc598b1939b4654441c64b96017448736d39f9ae2c
data/README.adoc CHANGED
@@ -35,8 +35,7 @@ The parameters are:
35
35
  `journaltemplate`:: template for rendering journals in article citations
36
36
  `extenttemplate`:: templates for rendering extents
37
37
  `sizetemplate`:: templates for rendering sizes
38
- `edition_number`:: override formatting of edition number
39
- `edition`:: override formatting of edition
38
+ `edition_ordinal`:: override formatting of edition with ordinal
40
39
  `date`:: default date format (from Twitter CLDR)
41
40
 
42
41
  == Configuration
@@ -133,6 +132,7 @@ The Liquid template surrounds each field by preceding and following punctuation.
133
132
  * If fields are not space-delimited, this is indicated by inserting `|`. So `{{ title }}|{{ medium}}` is two fields, rendered with no space separation.
134
133
  * 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.
135
134
  * Underscore is treated as space, attaching to the preceding or following field. So `,_{{ edition }}_{{ labels['edition'] }}` is treated as the one field.
135
+ * Underscore is escaped by \. So `<span_class="std\_note">` maps to `<span class="std_note">`.
136
136
  * 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.
137
137
  * Space between punctuation and before punctuation is automatically removed.
138
138
 
@@ -8,8 +8,10 @@ date:
8
8
  month_year: yMMMM
9
9
  day_month_year: to_long_s
10
10
  date_time: to_long_s
11
- edition_number: ["OrdinalRules", "digits-ordinal"]
12
- edition: "الطبعة؜ %؜"
11
+ ordinal_keys: []
12
+ OrdinalRules: digits-ordinal
13
+ edition_ordinal: "الطبعة؜ %Ordinal"
14
+ edition: الطبعة؜ ؜
13
15
  draft: "مشروع؜ %؜"
14
16
  editor:
15
17
  sg: محرر
@@ -28,4 +30,7 @@ size:
28
30
  volume:
29
31
  sg: "المجلد %"
30
32
  pl: "المجلدين %"
33
+ inflection:
34
+ الطبعة؜:
35
+ gender: f
31
36
 
@@ -9,7 +9,9 @@ date:
9
9
  day_month_year: to_long_s
10
10
  date_time: to_long_s
11
11
  draft: "Entwurf %"
12
- edition: "% Aufl."
12
+ edition_ordinal: "% Aufl."
13
+ ordinal_keys: []
14
+ edition: Auflage
13
15
  editor:
14
16
  sg: Hrsg.
15
17
  pl: Hrsg.
@@ -27,3 +29,7 @@ size:
27
29
  volume:
28
30
  sg: "% Bd."
29
31
  pl: "% Bde."
32
+ inflection:
33
+ Auflage:
34
+ gender: f
35
+
@@ -8,8 +8,10 @@ date:
8
8
  month_year: yMMMM
9
9
  day_month_year: to_long_s
10
10
  date_time: to_long_s
11
- edition_number: ["OrdinalRules", "digits-ordinal"]
12
- edition: "% edition"
11
+ ordinal_keys: []
12
+ OrdinalRules: digits-ordinal
13
+ edition: edition
14
+ edition_ordinal: "%Ordinal edition"
13
15
  draft: "draft %"
14
16
  editor:
15
17
  sg: ed.
@@ -8,8 +8,12 @@ date:
8
8
  month_year: yMMMM
9
9
  day_month_year: to_long_s
10
10
  date_time: to_long_s
11
- edition_number: ["OrdinalRules", "digits-ordinal-feminine"]
12
- edition: "% ed."
11
+ ordinal_keys: [gender]
12
+ OrdinalRules:
13
+ m: digits-ordinal-masculine
14
+ f: digits-ordinal-feminine
15
+ edition_ordinal: "%Ordinal ed."
16
+ edition: edición
13
17
  draft: "borrador %"
14
18
  editor:
15
19
  sg: ed.
@@ -28,3 +32,7 @@ size:
28
32
  volume:
29
33
  sg: "% vol."
30
34
  pl: "% vols."
35
+ inflection:
36
+ edición:
37
+ gender: f
38
+
@@ -8,8 +8,14 @@ date:
8
8
  month_year: yMMMM
9
9
  day_month_year: to_long_s
10
10
  date_time: to_long_s
11
- edition_number: ["OrdinalRules", "digits-ordinal-feminine"]
12
- edition: "% édition"
11
+ ordinal_keys: [gender,number]
12
+ OrdinalRules:
13
+ m.sg: digits-ordinal-masculine
14
+ f.sg: digits-ordinal-feminine
15
+ m.pl: digits-ordinal-masculine-plural
16
+ f.pl: digits-ordinal-feminine-plural
17
+ edition_ordinal: "%Ordinal édition"
18
+ edition: édition
13
19
  draft: "brouillon %"
14
20
  editor:
15
21
  sg: éd.
@@ -28,3 +34,7 @@ size:
28
34
  volume:
29
35
  sg: "% vol."
30
36
  pl: "% vol."
37
+ inflection:
38
+ édition:
39
+ gender: f
40
+
@@ -8,8 +8,16 @@ date:
8
8
  month_year: yMMMM
9
9
  day_month_year: to_long_s
10
10
  date_time: to_long_s
11
- edition_number: ["SpelloutRules", "spellout-ordinal-neuter"]
12
- edition: "% издание"
11
+ ordinal_keys: [gender,number]
12
+ SpelloutRules:
13
+ m.sg: spellout-ordinal-masculine
14
+ f.sg: spellout-ordinal-feminine
15
+ n.sg: spellout-ordinal-neuter
16
+ m.pl: spellout-ordinal-plural
17
+ f.pl: spellout-ordinal-plural
18
+ n.pl: spellout-ordinal-plural
19
+ edition_ordinal: "%Spellout издание"
20
+ edition: издание
13
21
  draft: "проект %"
14
22
  editor:
15
23
  sg: изд.
@@ -28,4 +36,7 @@ size:
28
36
  volume:
29
37
  sg: "% т."
30
38
  pl: "% тт."
39
+ inflection:
40
+ издание:
41
+ gender: n
31
42
 
@@ -8,8 +8,10 @@ date:
8
8
  month_year: yMMMM
9
9
  day_month_year: to_long_s
10
10
  date_time: to_long_s
11
- edition_number: ["OrdinalRules", "digits-ordinal"]
12
- edition: "第%版"
11
+ ordinal_keys: []
12
+ OrdinalRules: digits-ordinal
13
+ edition_ordinal: "第%Ordinal版"
14
+ edition: 版
13
15
  draft: "草案%"
14
16
  editor:
15
17
  sg: 编辑
@@ -98,10 +98,20 @@ module Relaton
98
98
  def editionformat(edn)
99
99
  return edn unless /^\d+$/.match?(edn)
100
100
 
101
- num = edn
102
- @r.edition_number and num = edn.to_i.localize(tw_cldr_lang)
103
- .to_rbnf_s(*@r.edition_number)
104
- @r.edition.sub(/%/, num)
101
+ num = edition_translate1(edn.to_i)
102
+ @r.edition_ordinal.sub(/%(Spellout|Ordinal)?/, num)
103
+ end
104
+
105
+ def edition_translate1(num)
106
+ ruleset = case @r.i18n.edition_ordinal
107
+ when /%Spellout/ then "SpelloutRules"
108
+ when /%Ordinal/ then "OrdinalRules"
109
+ else "Digit"
110
+ end
111
+ ruleset == "Digit" and return num.to_s
112
+ ed = HTMLEntities.new.decode(@r.i18n.edition)
113
+ @r.i18n.inflect_ordinal(num, @r.i18n.get["inflection"]&.dig(ed) || {},
114
+ ruleset)
105
115
  end
106
116
 
107
117
  def draftformat(num, _hash)
@@ -10,7 +10,7 @@ module Relaton
10
10
  class General
11
11
  attr_reader :template, :journaltemplate, :seriestemplate, :nametemplate,
12
12
  :extenttemplate, :sizetemplate, :lang, :script, :i18n,
13
- :edition, :edition_number, :date
13
+ :edition, :edition_ordinal, :date
14
14
 
15
15
  def initialize(opt = {})
16
16
  options = read_config.merge(Utils::string_keys(opt))
@@ -53,7 +53,7 @@ module Relaton
53
53
  @lang = opt["language"]
54
54
  @script = opt["script"]
55
55
  @i18n = i18n_klass(opt["language"], opt["script"])
56
- @edition_number = opt["edition_number"] || @i18n.edition_number
56
+ @edition_ordinal = opt["edition_ordinal"] || @i18n.edition_ordinal
57
57
  @edition = opt["edition"] || @i18n.edition
58
58
  @date = opt["date"] || @i18n.date
59
59
  end
@@ -80,7 +80,8 @@ module Relaton
80
80
  .gsub(/\s+([,.:;)])/, "\\1")
81
81
  .sub(/^\s*[,.:;]\s*/, "")
82
82
  .sub(/[,:;]\s*$/, "")
83
- .gsub(/_/, " ")
83
+ .gsub(/(?<!\\)_/, " ")
84
+ .gsub(/\\_/, "_")
84
85
  .gsub(/#{NON_SPACING_DELIM}/o, "").gsub(/\s+/, " ")
85
86
  end
86
87
 
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "0.3.3".freeze
3
+ VERSION = "0.3.5.1".freeze
4
4
  end
5
5
  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.3.3
4
+ version: 0.3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-25 00:00:00.000000000 Z
11
+ date: 2022-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler