relaton-render 0.3.4 → 0.3.6

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: ffb9cdf17ba3f47947a747bd8867ea9e7c47a98d458756ec947ee4423dc6b303
4
- data.tar.gz: d3a34c0f04cdb456517403b16fa3055ceb5e78162a44570e05ed5da16163c6ea
3
+ metadata.gz: 93d4f9e72050eae23fea0fb676616c4df3133ae9a4b3f0ec8b0cd9a877b57e21
4
+ data.tar.gz: bac7b85feccc54f9aa5b40d1540d2e39577dca6ca27fb99a0e4f297e6f5279c8
5
5
  SHA512:
6
- metadata.gz: 4a2aa5ae8d17b38ad0e79e575b9852127886a93ceafa5003ed1fc36d0bfb28e5a51733059b0a4c68256acdf62f3f1fd95195e68cf1e2b8d050fd753b6230f1a4
7
- data.tar.gz: 5bd29bd5368dc53408da0888cb11734a580041288132a0a73b1e93206849b527df5ee7bbb771734274be9d2927f098f9dea798bcdadd1c7d52ae2f909e52f1d7
6
+ metadata.gz: 49facfd7628fbdfbd6f86991fdfab0f92e2905abd5a0d63a29ba9e50f8158d9aa5e4b3cc7217d8ecf4a5c5c9611ebad8d91490b653402e6c9e6151d4f2889084
7
+ data.tar.gz: e9a3a707403dcd3fa57117766b3c18e6e87928b450d09d1cb45c7d97208a1a2b2dde67c9224e7d055654aa94c18d411ac7b687f943d39344fd60fefaa2307c38
data/README.adoc CHANGED
@@ -37,6 +37,7 @@ The parameters are:
37
37
  `sizetemplate`:: templates for rendering sizes
38
38
  `edition_ordinal`:: override formatting of edition with ordinal
39
39
  `date`:: default date format (from Twitter CLDR)
40
+ `i18nhash`:: Metanorma internationalisation hash
40
41
 
41
42
  == Configuration
42
43
 
@@ -132,6 +133,7 @@ The Liquid template surrounds each field by preceding and following punctuation.
132
133
  * If fields are not space-delimited, this is indicated by inserting `|`. So `{{ title }}|{{ medium}}` is two fields, rendered with no space separation.
133
134
  * 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.
134
135
  * Underscore is treated as space, attaching to the preceding or following field. So `,_{{ edition }}_{{ labels['edition'] }}` is treated as the one field.
136
+ * Underscore is escaped by \. So `<span_class="std\_note">` maps to `<span class="std_note">`.
135
137
  * 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.
136
138
  * Space between punctuation and before punctuation is automatically removed.
137
139
 
@@ -110,7 +110,7 @@ module Relaton
110
110
  end
111
111
  ruleset == "Digit" and return num.to_s
112
112
  ed = HTMLEntities.new.decode(@r.i18n.edition)
113
- @r.i18n.inflect_ordinal(num, @r.i18n.inflection&.dig(ed) || {},
113
+ @r.i18n.inflect_ordinal(num, @r.i18n.get["inflection"]&.dig(ed) || {},
114
114
  ruleset)
115
115
  end
116
116
 
@@ -19,7 +19,6 @@ module Relaton
19
19
  root_initalize(options)
20
20
  render_initialize(options)
21
21
  @parse ||= options["parse"]
22
- @i18n ||= options["i18n"]
23
22
  end
24
23
 
25
24
  def read_config
@@ -52,7 +51,8 @@ module Relaton
52
51
  def i18n_initialize(opt)
53
52
  @lang = opt["language"]
54
53
  @script = opt["script"]
55
- @i18n = i18n_klass(opt["language"], opt["script"])
54
+ @i18n = opt["i18n"] ||
55
+ i18n_klass(opt["language"], opt["script"], opt["i18nhash"])
56
56
  @edition_ordinal = opt["edition_ordinal"] || @i18n.edition_ordinal
57
57
  @edition = opt["edition"] || @i18n.edition
58
58
  @date = opt["date"] || @i18n.date
@@ -91,8 +91,8 @@ module Relaton
91
91
  "{{creatornames}}. {{title}}. {{date}}."
92
92
  end
93
93
 
94
- def i18n_klass(lang = "en", script = "Latn")
95
- ::IsoDoc::RelatonRenderI18n.new(lang, script)
94
+ def i18n_klass(lang = "en", script = "Latn", i18nhash = nil)
95
+ ::IsoDoc::RelatonRenderI18n.new(lang, script, i18nhash: i18nhash)
96
96
  end
97
97
 
98
98
  def render(bib, embedded: false)
@@ -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.4".freeze
3
+ VERSION = "0.3.6".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.4
4
+ version: 0.3.6
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-28 00:00:00.000000000 Z
11
+ date: 2022-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler