metanorma-generic 2.7.0 → 2.7.1

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: b3436616b2990529b36337c88267a1bb486c784760ee9e5dd44e8261d16d3a91
4
- data.tar.gz: d203b11d9d077960844d90a4245c19fcfdd533c917bc6fbda7d2600fa3c0a8eb
3
+ metadata.gz: bd710f710d4ac3b76fed5d6f647c2fec15372b84f2d86e01380a310b5d772db5
4
+ data.tar.gz: bf48530b643adc2078b880f6913df915bc8c6696d727e792baac2014f7605bb7
5
5
  SHA512:
6
- metadata.gz: 36d17d3720c65830aecaaec84e9cfda717044f1024112ed52cb2bea93ce65db0a31f3e55da1f7637bf2306b11bf0d69cc18b5e77818952aea9b6bdad1b1470e8
7
- data.tar.gz: 561e57900505474883823a8a6c7d7fb41b5fa6c49ae04ec284ba14d35dad45f520fa36881cc30dce6bc1298293c85f3ec1f3b2a2c20b3dc659d66308e739598f
6
+ metadata.gz: 8d45aca2e37d6987437b9cb12f287740d05a5c209c3f01f249b3ffa266995303cf62db2e391d10904344271da4058fb8b21ba6dcb228d600a88bb7dc134aeed6
7
+ data.tar.gz: c4f75e08a3ffe7f68dde7076fa94cb7209f1345a41fe423750e6110aebf5efd7676913998576dd594a72008157e2545d8e25c847ca19ba873330173f9edb878f
@@ -1000,14 +1000,14 @@
1000
1000
  <define name="PureTextElement">
1001
1001
  <choice>
1002
1002
  <text/>
1003
- <ref name="em"/>
1004
- <ref name="strong"/>
1003
+ <ref name="pure_em"/>
1004
+ <ref name="pure_strong"/>
1005
1005
  <ref name="sub"/>
1006
1006
  <ref name="sup"/>
1007
- <ref name="tt"/>
1008
- <ref name="underline"/>
1009
- <ref name="strike"/>
1010
- <ref name="smallcap"/>
1007
+ <ref name="pure_tt"/>
1008
+ <ref name="pure_underline"/>
1009
+ <ref name="pure_strike"/>
1010
+ <ref name="pure_smallcap"/>
1011
1011
  <ref name="br"/>
1012
1012
  </choice>
1013
1013
  </define>
@@ -1031,6 +1031,13 @@
1031
1031
  </zeroOrMore>
1032
1032
  </element>
1033
1033
  </define>
1034
+ <define name="pure_em">
1035
+ <element name="em">
1036
+ <zeroOrMore>
1037
+ <ref name="PureTextElement"/>
1038
+ </zeroOrMore>
1039
+ </element>
1040
+ </define>
1034
1041
  <define name="strong">
1035
1042
  <element name="strong">
1036
1043
  <zeroOrMore>
@@ -1046,6 +1053,13 @@
1046
1053
  </zeroOrMore>
1047
1054
  </element>
1048
1055
  </define>
1056
+ <define name="pure_strong">
1057
+ <element name="strong">
1058
+ <zeroOrMore>
1059
+ <ref name="PureTextElement"/>
1060
+ </zeroOrMore>
1061
+ </element>
1062
+ </define>
1049
1063
  <define name="tt">
1050
1064
  <element name="tt">
1051
1065
  <zeroOrMore>
@@ -1060,6 +1074,13 @@
1060
1074
  </zeroOrMore>
1061
1075
  </element>
1062
1076
  </define>
1077
+ <define name="pure_tt">
1078
+ <element name="tt">
1079
+ <zeroOrMore>
1080
+ <ref name="PureTextElement"/>
1081
+ </zeroOrMore>
1082
+ </element>
1083
+ </define>
1063
1084
  <define name="keyword">
1064
1085
  <element name="keyword">
1065
1086
  <zeroOrMore>
@@ -1090,13 +1111,42 @@
1090
1111
  <zeroOrMore>
1091
1112
  <choice>
1092
1113
  <ref name="PureTextElement"/>
1114
+ <ref name="stem"/>
1115
+ <ref name="eref"/>
1116
+ <ref name="xref"/>
1117
+ <ref name="hyperlink"/>
1093
1118
  <ref name="index"/>
1094
1119
  <ref name="index-xref"/>
1095
1120
  </choice>
1096
1121
  </zeroOrMore>
1097
1122
  </element>
1098
1123
  </define>
1124
+ <define name="pure_strike">
1125
+ <element name="strike">
1126
+ <zeroOrMore>
1127
+ <ref name="PureTextElement"/>
1128
+ </zeroOrMore>
1129
+ </element>
1130
+ </define>
1099
1131
  <define name="underline">
1132
+ <element name="underline">
1133
+ <optional>
1134
+ <attribute name="style"/>
1135
+ </optional>
1136
+ <zeroOrMore>
1137
+ <choice>
1138
+ <ref name="PureTextElement"/>
1139
+ <ref name="stem"/>
1140
+ <ref name="eref"/>
1141
+ <ref name="xref"/>
1142
+ <ref name="hyperlink"/>
1143
+ <ref name="index"/>
1144
+ <ref name="index-xref"/>
1145
+ </choice>
1146
+ </zeroOrMore>
1147
+ </element>
1148
+ </define>
1149
+ <define name="pure_underline">
1100
1150
  <element name="underline">
1101
1151
  <optional>
1102
1152
  <attribute name="style"/>
@@ -1107,6 +1157,21 @@
1107
1157
  </element>
1108
1158
  </define>
1109
1159
  <define name="smallcap">
1160
+ <element name="smallcap">
1161
+ <zeroOrMore>
1162
+ <choice>
1163
+ <ref name="PureTextElement"/>
1164
+ <ref name="stem"/>
1165
+ <ref name="eref"/>
1166
+ <ref name="xref"/>
1167
+ <ref name="hyperlink"/>
1168
+ <ref name="index"/>
1169
+ <ref name="index-xref"/>
1170
+ </choice>
1171
+ </zeroOrMore>
1172
+ </element>
1173
+ </define>
1174
+ <define name="pure_smallcap">
1110
1175
  <element name="smallcap">
1111
1176
  <zeroOrMore>
1112
1177
  <ref name="PureTextElement"/>
@@ -1204,7 +1204,9 @@
1204
1204
  <optional>
1205
1205
  <ref name="formattedref"/>
1206
1206
  </optional>
1207
- <ref name="btitle"/>
1207
+ <oneOrMore>
1208
+ <ref name="btitle"/>
1209
+ </oneOrMore>
1208
1210
  <optional>
1209
1211
  <ref name="bplace"/>
1210
1212
  </optional>
@@ -2,6 +2,8 @@ require "asciidoctor"
2
2
  require "metanorma/standoc/converter"
3
3
  require "fileutils"
4
4
  require_relative "front"
5
+ require "metanorma"
6
+ require "pathname"
5
7
 
6
8
  module Metanorma
7
9
  module Generic
@@ -20,20 +22,17 @@ module Metanorma
20
22
  end
21
23
 
22
24
  def baselocation(loc)
23
- return nil if loc.nil?
24
-
25
+ loc.nil? and return nil
25
26
  return loc
26
- File.expand_path(File.join(File.dirname(
27
- self.class::_file || __FILE__,
28
- ), "..", "..", "..", loc))
29
27
  end
30
28
 
31
29
  def docidentifier_cleanup(xmldoc)
30
+ b = boilerplate_isodoc(xmldoc) or return
32
31
  template = configuration.docid_template ||
33
32
  "{{ organization_name_short }} {{ docnumeric }}"
34
33
  docid = xmldoc.at("//bibdata/docidentifier")
35
34
  docid&.text&.empty? or return
36
- id = boilerplate_isodoc(xmldoc).populate_template(template, nil)
35
+ id = b.populate_template(template, nil)
37
36
  (id.empty? and docid.remove) or docid.children = id
38
37
  end
39
38
 
@@ -58,6 +57,10 @@ module Metanorma
58
57
  def read_config_file(path_to_config_file)
59
58
  Metanorma::Generic.configuration
60
59
  .set_default_values_from_yaml_file(path_to_config_file)
60
+ # reregister Processor to Metanorma with updated values
61
+ if defined? Metanorma::Registry
62
+ Metanorma::Registry.instance.register(Metanorma::Generic::Processor)
63
+ end
61
64
  end
62
65
 
63
66
  def sectiontype_streamline(ret)
@@ -75,7 +78,12 @@ module Metanorma
75
78
  end
76
79
 
77
80
  def document(node)
78
- read_config_file(node.attr("customize")) if node.attr("customize")
81
+ if node.attr("customize")
82
+ p = node.attr("customize")
83
+ (Pathname.new p).absolute? or
84
+ p = File.expand_path(File.join(Metanorma::Utils::localdir(node), p))
85
+ read_config_file(p)
86
+ end
79
87
  super
80
88
  end
81
89
 
@@ -158,7 +166,7 @@ module Metanorma
158
166
  end
159
167
 
160
168
  def boilerplate_isodoc(xmldoc)
161
- conv = super
169
+ conv = super or return nil
162
170
  Metanorma::Generic::Configuration::CONFIG_ATTRS.each do |a|
163
171
  conv.meta.set(a, configuration.send(a))
164
172
  end
@@ -662,6 +662,9 @@
662
662
  <value>LatexMath</value>
663
663
  </choice>
664
664
  </attribute>
665
+ <optional>
666
+ <attribute name="number-format"/>
667
+ </optional>
665
668
  <attribute name="block">
666
669
  <data type="boolean"/>
667
670
  </attribute>
@@ -15,10 +15,7 @@ module Metanorma
15
15
  end
16
16
 
17
17
  def output_formats
18
- super.merge(
19
- html: "html",
20
- doc: "doc",
21
- )
18
+ configuration.formats
22
19
  end
23
20
 
24
21
  def fonts_manifest
@@ -66,6 +66,9 @@
66
66
  <ref name="MultilingualRenderingType"/>
67
67
  </attribute>
68
68
  </optional>
69
+ <optional>
70
+ <attribute name="class"/>
71
+ </optional>
69
72
  <optional>
70
73
  <ref name="reqtitle"/>
71
74
  </optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "2.7.0".freeze
3
+ VERSION = "2.7.1".freeze
4
4
  end
5
5
  end
@@ -10,6 +10,10 @@ module Metanorma
10
10
  DOCUMENT_NAMESPACE = "https://www.metanorma.org/ns/generic"
11
11
  YAML_CONFIG_FILE = "metanorma.yml"
12
12
 
13
+ class DummyProcessor < ::Metanorma::Processor
14
+ def initialize; end # rubocop:disable Lint/MissingSuper
15
+ end
16
+
13
17
  class Configuration
14
18
  CONFIG_ATTRS = %i[
15
19
  organization_name_short
@@ -62,6 +66,7 @@ module Metanorma
62
66
  word_footnotefontsize
63
67
  xml_root_tag
64
68
  pdf_stylesheet
69
+ formats
65
70
  ].freeze
66
71
 
67
72
  def filepath_attrs
@@ -86,11 +91,31 @@ module Metanorma
86
91
  # Try to set config values from yaml file in current directory
87
92
  @yaml = File.join(File.dirname(self.class::_file || __FILE__), "..",
88
93
  "..", YAML_CONFIG_FILE)
89
- set_default_values_from_yaml_file(@yaml) if File.file?(@yaml)
94
+ set_default_values_from_yaml_file(@yaml)
95
+ end
96
+
97
+ # may be invoked multiple times, needs to not overwrite
98
+ def postprocess_defaults
99
+ default_org
100
+ default_formats
101
+ default_titles
102
+ end
103
+
104
+ def default_org
90
105
  self.organization_name_short ||= ORGANIZATION_NAME_SHORT
91
106
  self.organization_name_long ||= ORGANIZATION_NAME_LONG
92
107
  self.document_namespace ||= DOCUMENT_NAMESPACE
93
- default_titles
108
+ end
109
+
110
+ # convert array to hash; if already is hash (no override in customize),
111
+ # don't reconvert
112
+ def default_formats
113
+ formats.is_a?(Hash) and return
114
+ self.formats ||= %w(html doc)
115
+ self.formats = self.formats.each_with_object({}) do |k, m|
116
+ m[k.to_sym] = k
117
+ end
118
+ self.formats.merge! DummyProcessor.new.output_formats
94
119
  end
95
120
 
96
121
  def default_titles
@@ -107,18 +132,25 @@ module Metanorma
107
132
  end
108
133
 
109
134
  def set_default_values_from_yaml_file(config_file)
110
- root_path, default_config_options =
111
- set_default_values_from_yaml_file_prep(config_file)
112
- CONFIG_ATTRS.each do |attr_name|
113
- value = default_config_options[attr_name.to_s]
114
- value && filepath_attrs.include?(attr_name) and
115
- value = absolute_path(value, root_path)
116
- instance_variable_set("@#{attr_name}", value)
135
+ if File.file?(config_file)
136
+ root_path, default_config_options =
137
+ set_default_values_from_yaml_file_prep(config_file)
138
+ CONFIG_ATTRS.each do |attr|
139
+ set_default_value_from_yaml_file(attr, root_path,
140
+ default_config_options)
141
+ end
117
142
  end
143
+ postprocess_defaults
144
+ end
145
+
146
+ def set_default_value_from_yaml_file(attr, root_path, default_options)
147
+ value = default_options[attr.to_s]
148
+ value && filepath_attrs.include?(attr) and
149
+ value = absolute_path(value, root_path)
150
+ instance_variable_set("@#{attr}", value)
118
151
  end
119
152
 
120
153
  def set_default_values_from_yaml_file_prep(config_file)
121
- # root_path = File.dirname(self.class::_file || __FILE__)
122
154
  root_path = File.dirname(config_file)
123
155
  default_config_options =
124
156
  YAML.safe_load(File.read(config_file, encoding: "UTF-8"))
@@ -135,11 +167,14 @@ module Metanorma
135
167
  end
136
168
 
137
169
  def absolute_path(value, root_path)
138
- if value.is_a? Hash then absolute_path1(value, root_path)
139
- elsif value.is_a? Array then absolute_path1_array(value, root_path)
140
- elsif value.is_a?(String) && !value.empty? &&
141
- !Pathname.new(value).absolute?
142
- Pathname.new(File.join(root_path, value)).cleanpath.to_s
170
+ case value
171
+ when Hash then absolute_path1(value, root_path)
172
+ when Array then absolute_path1_array(value, root_path)
173
+ when String
174
+ if !value.empty? && !Pathname.new(value).absolute?
175
+ Pathname.new(File.join(root_path, value)).cleanpath.to_s
176
+ else value
177
+ end
143
178
  else value
144
179
  end
145
180
  end
@@ -8,6 +8,10 @@ logo_paths:
8
8
  - /metanorma-mine/lib/isodoc/mine/html/logo1.jpg
9
9
  - /metanorma-mine/lib/isodoc/mine/html/logo2.jpg
10
10
  validate_rng_file: /metanorma-mine/lib/metanorma/mine/mine.rng
11
+ formats:
12
+ - html
13
+ - pdf
14
+ - doc
11
15
  htmlcoverpage: /metanorma-mine/lib/isodoc/mine/html/html_mine_titlepage.html
12
16
  htmlintropage: /metanorma-mine/lib/isodoc/mine/html/html_mine_intro.html
13
17
  htmlstylesheet: /metanorma-mine/lib/isodoc/mine/html/htmlstyle.scss
@@ -74,5 +78,5 @@ normref_titles:
74
78
  bibliography_titles:
75
79
  - Bibliography
76
80
  fonts_manifest:
77
- - Font1
78
- - Font2
81
+ Font1:
82
+ Font2:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-generic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.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: 2024-08-19 00:00:00.000000000 Z
11
+ date: 2024-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc