metanorma-plateau 1.1.6 → 1.2.0

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.
@@ -1,4 +1,5 @@
1
1
  require_relative "init"
2
+ require_relative "../../relaton/render-plateau/general"
2
3
 
3
4
  module IsoDoc
4
5
  module Plateau
@@ -98,6 +99,36 @@ module IsoDoc
98
99
  end
99
100
  end
100
101
 
102
+ def anchor_linkend(node, linkend)
103
+ title_fallback_docid?(node) and
104
+ node["style"] ||= "title"
105
+ super
106
+ end
107
+
108
+ # if we are falling back to a title identifier for citation,
109
+ # cite title-style, which gives us title marks
110
+ def title_fallback_docid?(elem)
111
+ sem_xml_descendant?(elem) and return
112
+ id = elem["bibitemid"] or return
113
+ b = @bibitem_lookup[id] or return
114
+ x = <<~XPATH
115
+ ./docidentifier[not(#{SKIP_DOCID} or @scope = 'biblio-tag' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type='title')]
116
+ XPATH
117
+ !b.at(ns(x)) && b.at(ns("./docidentifier[@type='title']"))
118
+ end
119
+
120
+ def termsource_join_delim(_elem)
121
+ @lang == "ja" ? "/" : "/"
122
+ end
123
+
124
+ def source_join_delim(_elem)
125
+ @lang == "ja" ? "/" : "/"
126
+ end
127
+
128
+ def termsource_mod_text_delim(_elem)
129
+ @lang == "ja" ? "、" : ", "
130
+ end
131
+
101
132
  include Init
102
133
  end
103
134
  end
@@ -869,7 +869,7 @@ depending on whether the items exist as independent documents, or are parts of a
869
869
  </zeroOrMore>
870
870
  </element>
871
871
  </define>
872
- <define name="BibItemType" combine="choice">
872
+ <define name="BibItemType">
873
873
  <a:documentation>Type of bibliographic item.
874
874
  The value list complies with the types provided in ISO 690:2021.
875
875
  NOTE: These values represent a strict superset to BibTeX
@@ -39,8 +39,7 @@ module Metanorma
39
39
 
40
40
  def doctype_validate(_xmldoc)
41
41
  %w(handbook technical-report annex).include? @doctype or
42
- @log.add("Document Attributes", nil,
43
- "#{@doctype} is not a recognised document type")
42
+ @log.add("PLATEAU_1", nil, params: [@doctype])
44
43
  end
45
44
 
46
45
  def metadata_id(node, xml)
@@ -100,3 +99,5 @@ module Metanorma
100
99
  end
101
100
  end
102
101
  end
102
+
103
+ require_relative "log"
@@ -311,17 +311,28 @@ and is intended to be referenced by a callout within the source code</a:document
311
311
  </ref>
312
312
  </optional>
313
313
  <choice>
314
- <a:documentation>Content of the figure</a:documentation>
315
- <ref name="image"/>
314
+ <a:documentation>Content of the figure </a:documentation>
315
+ <ref name="image">
316
+ <a:documentation>by default the content of a figure is a media file</a:documentation>
317
+ </ref>
316
318
  <ref name="video"/>
317
319
  <ref name="audio"/>
318
- <ref name="pre"/>
320
+ <ref name="pre">
321
+ <a:documentation>figures can contain ASCII art</a:documentation>
322
+ </ref>
319
323
  <oneOrMore>
320
- <ref name="paragraph-with-footnote"/>
324
+ <ref name="paragraph-with-footnote">
325
+ <a:documentation>figures can contain discursive art</a:documentation>
326
+ </ref>
321
327
  </oneOrMore>
322
328
  <zeroOrMore>
323
- <ref name="figure"/>
329
+ <ref name="figure">
330
+ <a:documentation>subfigures, nested directly within a figure</a:documentation>
331
+ </ref>
324
332
  </zeroOrMore>
333
+ <ref name="table">
334
+ <a:documentation>Table is understood in this context to be a tabular arrangement of subfigures</a:documentation>
335
+ </ref>
325
336
  </choice>
326
337
  <zeroOrMore>
327
338
  <ref name="fn">
@@ -354,17 +365,28 @@ and is intended to be referenced by a callout within the source code</a:document
354
365
  </ref>
355
366
  </optional>
356
367
  <choice>
357
- <a:documentation>Content of the figure</a:documentation>
358
- <ref name="image-no-id"/>
368
+ <a:documentation>Content of the figure </a:documentation>
369
+ <ref name="image-no-id">
370
+ <a:documentation>by default the content of a figure is a media file</a:documentation>
371
+ </ref>
359
372
  <ref name="video-no-id"/>
360
373
  <ref name="audio-no-id"/>
361
- <ref name="pre-no-id"/>
374
+ <ref name="pre-no-id">
375
+ <a:documentation>figures can contain ASCII art</a:documentation>
376
+ </ref>
362
377
  <oneOrMore>
363
- <ref name="paragraph-with-footnote-no-id"/>
378
+ <ref name="paragraph-with-footnote-no-id">
379
+ <a:documentation>figures can contain discursive art</a:documentation>
380
+ </ref>
364
381
  </oneOrMore>
365
382
  <zeroOrMore>
366
- <ref name="figure-no-id"/>
383
+ <ref name="figure-no-id">
384
+ <a:documentation>subfigures, nested directly within a figure</a:documentation>
385
+ </ref>
367
386
  </zeroOrMore>
387
+ <ref name="table-no-id">
388
+ <a:documentation>Table is understood in this context to be a tabular arrangement of subfigures</a:documentation>
389
+ </ref>
368
390
  </choice>
369
391
  <zeroOrMore>
370
392
  <ref name="fn">
@@ -876,6 +898,9 @@ titlecase, or lowercase</a:documentation>
876
898
  <data type="boolean"/>
877
899
  </attribute>
878
900
  </optional>
901
+ <ref name="LocalizedStringAttributes">
902
+ <a:documentation>Specify language of bibitem, can be used to render it with language-specific bibliographic style</a:documentation>
903
+ </ref>
879
904
  <ref name="ReducedBibliographicItem"/>
880
905
  </element>
881
906
  </define>
@@ -0,0 +1,17 @@
1
+ module Metanorma
2
+ module Plateau
3
+ class Converter
4
+ PLATEAU_LOG_MESSAGES = {
5
+ # rubocop:disable Naming/VariableNumber
6
+ "PLATEAU_1": { category: "Document Attributes",
7
+ error: "%s is not a recognised document type",
8
+ severity: 2 },
9
+ }.freeze
10
+ # rubocop:enable Naming/VariableNumber
11
+
12
+ def log_messages
13
+ super.merge(PLATEAU_LOG_MESSAGES)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Plateau
3
- VERSION = "1.1.6".freeze
3
+ VERSION = "1.2.0".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,9 @@
1
+ module Relaton
2
+ module Render
3
+ class Citations
4
+ def renderer(cite)
5
+ @renderer[cite.dig(:data, :language)&.to_sym || @lang.to_sym]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,91 @@
1
+ require "relaton-render"
2
+ require "metanorma-jis"
3
+ require_relative "citations"
4
+ require_relative "i18n"
5
+ require "isodoc-i18n"
6
+ require_relative "../../isodoc/plateau/i18n"
7
+
8
+ module Relaton
9
+ module Render
10
+ module Plateau
11
+ class General < ::Relaton::Render::Jis::General
12
+ def initialize(opt = {})
13
+ i18n = opt[:i18n] ||
14
+ i18n_klass(language: opt[:language], script: opt[:script],
15
+ locale: opt[:locale], i18nhash: opt[:i18nhash])
16
+ opt["i18n_multi"] = {
17
+ en: i18n_config("en", i18n),
18
+ ja: i18n_config("ja", i18n),
19
+ }
20
+ super
21
+ end
22
+
23
+ def klass_initialize(_options)
24
+ super
25
+ @i18nklass = Relaton::Render::Plateau::I18n
26
+ end
27
+
28
+ def deep_clone(obj)
29
+ Marshal.load(Marshal.dump(obj))
30
+ end
31
+
32
+ def citation_renderers
33
+ { en: bibrenderer_lang("en", deep_clone(@config)),
34
+ ja: bibrenderer_lang("ja", deep_clone(@config)) }
35
+ end
36
+
37
+ SWITCH_PUNCT_KEYS =
38
+ %w(open-title close-title open-secondary-title close-secondary-title
39
+ biblio-field-delimiter comma).freeze
40
+
41
+ # cit_i18n is citation lang i18n
42
+ # @i18n is document lang i18n
43
+ # return merger of the two
44
+ # KILL
45
+ def bibrenderer_lang_config(lang)
46
+ script = lang == "ja" ? "Jpan" : "Latn"
47
+ cit_i18n = ::IsoDoc::Plateau::I18n.new(lang, script).get
48
+ i18n = deep_clone(@i18n.get)
49
+ SWITCH_PUNCT_KEYS.each { |k| i18n["punct"][k] = cit_i18n["punct"][k] }
50
+ # keep Latin punct half-width in Japanese context
51
+ lang == "en" and
52
+ i18n["punct"]["biblio-field-delimiter"] = "<esc>.</esc> "
53
+ i18n
54
+ end
55
+
56
+ # cit_i18n is citation lang i18n
57
+ # i18n is document lang i18n
58
+ # return customised merger of the two
59
+ def i18n_config(lang, i18n)
60
+ script = lang == "ja" ? "Jpan" : "Latn"
61
+ cit_i18n = ::IsoDoc::Plateau::I18n.new(lang, script)
62
+ i18n = deep_clone(i18n)
63
+ punct = i18n.get["punct"]
64
+ SWITCH_PUNCT_KEYS.each { |k| punct[k] = cit_i18n.get["punct"][k] }
65
+ # keep Latin punct half-width in Japanese context
66
+ lang == "en" and
67
+ punct["biblio-field-delimiter"] = "<esc>.</esc> "
68
+ i18n.set("punct", punct)
69
+ i18n.set("author_and", cit_i18n.get["author_and"])
70
+ i18n
71
+ end
72
+
73
+ def bibrenderer_lang(lang, options)
74
+ yaml, script = bibrenderer_lang_prep(lang)
75
+ # i18n = bibrenderer_lang_config(lang)
76
+ i18n = i18n_config(lang, @i18n.config[@lang]).get
77
+ ::Relaton::Render::Plateau::General.new(options
78
+ .deep_merge(yaml)
79
+ .merge(language: lang, script: script, i18nhash: i18n))
80
+ end
81
+
82
+ def bibrenderer_lang_prep(lang)
83
+ yaml = YAML.load_file(File.join(File.dirname(__FILE__),
84
+ "config-#{lang}.yml"))
85
+ script = lang == "ja" ? "Jpan" : "Latn"
86
+ [yaml, script]
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,21 @@
1
+ module Relaton
2
+ module Render
3
+ module Plateau
4
+ class I18n < ::Relaton::Render::I18n
5
+ def initialize(opt)
6
+ super
7
+ #require "debug"; binding.b
8
+ @lang = opt["language"]
9
+ end
10
+
11
+ def select_default
12
+ @i18n[@lang]
13
+ end
14
+
15
+ def select_obj(obj)
16
+ @i18n[obj[:language]]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
31
31
 
32
- spec.add_dependency "metanorma-jis", "~> 0.6.0"
32
+ spec.add_dependency "metanorma-jis", "~> 1.0.0"
33
33
  spec.add_dependency "pubid"
34
34
 
35
35
  spec.add_development_dependency "debug"
@@ -40,10 +40,11 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "rake", "~> 13.0"
41
41
  spec.add_development_dependency "rspec", "~> 3.6"
42
42
  spec.add_development_dependency "rubocop", "~> 1"
43
- spec.add_development_dependency "rubocop-performance"
43
+ spec.add_development_dependency "rubocop-performance"
44
44
  spec.add_development_dependency "sassc-embedded", "~> 1"
45
45
  spec.add_development_dependency "simplecov", "~> 0.15"
46
46
  spec.add_development_dependency "timecop", "~> 0.9"
47
47
  spec.add_development_dependency "webmock"
48
- spec.add_development_dependency "canon"
48
+ spec.add_development_dependency "openssl"
49
+ spec.add_development_dependency "canon", "= 0.1.3"
49
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-plateau
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-jis
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.0
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.0
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pubid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -221,7 +221,7 @@ dependencies:
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
- name: canon
224
+ name: openssl
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: canon
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - '='
242
+ - !ruby/object:Gem::Version
243
+ version: 0.1.3
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '='
249
+ - !ruby/object:Gem::Version
250
+ version: 0.1.3
237
251
  description: |
238
252
  Metanorma standards authoring environment for MLIT Project PLATEAU.
239
253
 
@@ -271,11 +285,17 @@ files:
271
285
  - lib/metanorma/plateau/isodoc.rng
272
286
  - lib/metanorma/plateau/isostandard.rng
273
287
  - lib/metanorma/plateau/jis.rng
288
+ - lib/metanorma/plateau/log.rb
274
289
  - lib/metanorma/plateau/plateau.rng
275
290
  - lib/metanorma/plateau/processor.rb
276
291
  - lib/metanorma/plateau/relaton-jis.rng
277
292
  - lib/metanorma/plateau/reqt.rng
278
293
  - lib/metanorma/plateau/version.rb
294
+ - lib/relaton/render-plateau/citations.rb
295
+ - lib/relaton/render-plateau/config-en.yml
296
+ - lib/relaton/render-plateau/config-ja.yml
297
+ - lib/relaton/render-plateau/general.rb
298
+ - lib/relaton/render-plateau/i18n.rb
279
299
  - metanorma-plateau.gemspec
280
300
  homepage: https://github.com/metanorma/metanorma-plateau
281
301
  licenses: