metanorma-standoc 3.0.8 → 3.0.10

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/html/htmlstyle.css +0 -2
  3. data/lib/metanorma/standoc/anchor.rb +1 -1
  4. data/lib/metanorma/standoc/blocks.rb +12 -5
  5. data/lib/metanorma/standoc/blocks_image.rb +3 -8
  6. data/lib/metanorma/standoc/blocks_notes.rb +1 -1
  7. data/lib/metanorma/standoc/cleanup.rb +5 -1
  8. data/lib/metanorma/standoc/cleanup_bibdata.rb +1 -1
  9. data/lib/metanorma/standoc/cleanup_bibitem.rb +3 -2
  10. data/lib/metanorma/standoc/cleanup_footnotes.rb +1 -0
  11. data/lib/metanorma/standoc/cleanup_inline.rb +13 -12
  12. data/lib/metanorma/standoc/cleanup_section.rb +25 -3
  13. data/lib/metanorma/standoc/cleanup_section_names.rb +3 -2
  14. data/lib/metanorma/standoc/cleanup_terms.rb +14 -3
  15. data/lib/metanorma/standoc/cleanup_text.rb +5 -3
  16. data/lib/metanorma/standoc/converter.rb +17 -8
  17. data/lib/metanorma/standoc/init.rb +9 -3
  18. data/lib/metanorma/standoc/inline.rb +5 -0
  19. data/lib/metanorma/standoc/isodoc.rng +32 -2
  20. data/lib/metanorma/standoc/lists.rb +2 -2
  21. data/lib/metanorma/standoc/macros.rb +46 -2
  22. data/lib/metanorma/standoc/macros_inline.rb +44 -4
  23. data/lib/metanorma/standoc/macros_link.rb +9 -0
  24. data/lib/metanorma/standoc/macros_plantuml.rb +28 -14
  25. data/lib/metanorma/standoc/ref_sect.rb +2 -2
  26. data/lib/metanorma/standoc/render.rb +22 -13
  27. data/lib/metanorma/standoc/section.rb +20 -15
  28. data/lib/metanorma/standoc/sectiontype.rb +28 -20
  29. data/lib/metanorma/standoc/table.rb +2 -6
  30. data/lib/metanorma/standoc/term_lookup_cleanup.rb +0 -9
  31. data/lib/metanorma/standoc/terms.rb +4 -3
  32. data/lib/metanorma/standoc/utils.rb +4 -0
  33. data/lib/metanorma/standoc/version.rb +1 -1
  34. data/metanorma-standoc.gemspec +1 -2
  35. metadata +4 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6effed725121e1f1924a44b86be0de3ebd4bcf5cc1349b07c3933a1b8666ffdf
4
- data.tar.gz: 3def10482963835400c5f5e9c7f1283ba26311a1bd82da6319633ab6186ea561
3
+ metadata.gz: db6d5e84280a719a76127b82021c52b54a140d3238f49ee7a5ac7c972d142e37
4
+ data.tar.gz: a0b7796f74365c18f35d05b27bffc7fbb369def03e1d29753ddeb7adbc9bef86
5
5
  SHA512:
6
- metadata.gz: 39cd5c14eebf34d92214d6c76c9f8cd2aa72e4eed77d31998d629174096439dcab567326d565c7540e3ffe1aa7dfcd87c11f7f31148f6bc4a1895adad240dab6
7
- data.tar.gz: f88823d2442c1ce9eadb24b34985cc5aba32a121531c01341a1da0483ce9273dc881a90f32ce22319018458028bffd0feb313584c11e39aa088badf298b3f4eb
6
+ metadata.gz: f6991e701daa845955fc12f72f602eab1947ff397ecad2e8514e3ec9a9b04fdfa68fa0e6d946b3a8d53ae6d1feb8fcb78ff81f5d71e17ffa580157cda891ccde
7
+ data.tar.gz: d9025688e127d12e7103537af3d8d6f50b8d1c6a67eff352a365a0ebcb67acb7d976bbfb391dd30980df56b193bf3a56c99d98db6f326e4ede057cc29b3bf935
@@ -320,8 +320,6 @@ h6:hover > a.anchor,
320
320
 
321
321
  svg {
322
322
  width: 100%;
323
- padding-bottom: 92%;
324
- height: 1px;
325
323
  overflow: visible;
326
324
  }
327
325
 
@@ -121,7 +121,7 @@ module Metanorma
121
121
  @fn_number ||= 0
122
122
  noko do |xml|
123
123
  @fn_number += 1
124
- xml.fn reference: @fn_number do |fn|
124
+ xml.fn **attr_code(id_attr(nil).merge(reference: @fn_number)) do |fn|
125
125
  fn.p { |p| p << node.text }
126
126
  end
127
127
  end
@@ -47,6 +47,13 @@ module Metanorma
47
47
  result
48
48
  end
49
49
 
50
+ def block_title(node, out)
51
+ node.title.nil? and return
52
+ out.name **attr_code(id_attr(nil)) do |name|
53
+ name << node.title
54
+ end
55
+ end
56
+
50
57
  def form_attrs(node)
51
58
  attr_code(id_attr(node)
52
59
  .merge(class: node.attr("class"),
@@ -68,7 +75,7 @@ module Metanorma
68
75
  def literal(node)
69
76
  noko do |xml|
70
77
  xml.figure **literal_attrs(node) do |f|
71
- figure_title(node, f)
78
+ block_title(node, f)
72
79
  pre_attrs = id_attr(node).tap { |h| h.delete(:anchor) }
73
80
  .merge(alt: node.attr("alt"))
74
81
  f.pre node.lines.join("\n"), **attr_code(pre_attrs)
@@ -128,7 +135,7 @@ module Metanorma
128
135
  node.blocks.each { |b| b.remove_sub(:replacements) }
129
136
  noko do |xml|
130
137
  xml.figure **example_attrs(node).merge(class: "pseudocode") do |ex|
131
- figure_title(node, ex)
138
+ block_title(node, ex)
132
139
  wrap_in_para(node, ex)
133
140
  end
134
141
  end
@@ -141,7 +148,7 @@ module Metanorma
141
148
  def example_proper(node)
142
149
  noko do |xml|
143
150
  xml.example **example_attrs(node) do |ex|
144
- node.title.nil? or ex.name { |name| name << node.title }
151
+ block_title(node, xml)
145
152
  wrap_in_para(node, ex)
146
153
  end
147
154
  end
@@ -203,7 +210,7 @@ module Metanorma
203
210
  def listing(node)
204
211
  fragment = ::Nokogiri::XML::Builder.new do |xml|
205
212
  xml.sourcecode **listing_attrs(node) do |s|
206
- figure_title(node, s)
213
+ block_title(node, s)
207
214
  s.body do |b|
208
215
  b << node.content
209
216
  end
@@ -232,7 +239,7 @@ module Metanorma
232
239
 
233
240
  # need to validate Metanorma XML before it passes to textcleanup,
234
241
  # where passthrough wrapper and escaped tags are removed:
235
- # <passthrough format="metanorma>&lt;tag&gt</passthrough> => <tag>
242
+ # <passthrough formats="metanorma>&lt;tag&gt</passthrough> => <tag>
236
243
  # Do not treat not well-formed XML as invalid,
237
244
  # as it may be fragment, e.g. unterminated start of element markup
238
245
  def passthrough_validate(node, content, encoded_content)
@@ -10,7 +10,7 @@ module Metanorma
10
10
  xml.svgmap **attr_code(svgmap_attrs(node).merge(
11
11
  src: node.attr("src"), alt: node.attr("alt"),
12
12
  )) do |ex|
13
- figure_title(node, ex)
13
+ block_title(node, ex)
14
14
  ex << node.content
15
15
  end
16
16
  end
@@ -19,17 +19,12 @@ module Metanorma
19
19
  def figure_example(node)
20
20
  noko do |xml|
21
21
  xml.figure **figure_attrs(node) do |ex|
22
- node.title.nil? or ex.name { |name| name << node.title }
22
+ block_title(node, ex)
23
23
  wrap_in_para(node, ex)
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
- def figure_title(node, out)
29
- node.title.nil? and return
30
- out.name { |name| name << node.title }
31
- end
32
-
33
28
  def figure_attrs(node)
34
29
  attr_code(id_unnum_attrs(node).merge(keep_attrs(node))
35
30
  .merge(class: node.attr("class"),
@@ -39,7 +34,7 @@ module Metanorma
39
34
  def image(node)
40
35
  noko do |xml|
41
36
  xml.figure **figure_attrs(node) do |f|
42
- figure_title(node, f)
37
+ block_title(node, f)
43
38
  f.image **(image_attributes(node).tap { |h| h.delete(:anchor) })
44
39
  end
45
40
  end
@@ -96,7 +96,7 @@ module Metanorma
96
96
  ret = admonition_alternatives(node) and return ret
97
97
  noko do |xml|
98
98
  xml.admonition **admonition_attrs(node) do |a|
99
- node.title.nil? or a.name { |name| name << node.title }
99
+ block_title(node, a)
100
100
  wrap_in_para(node, a)
101
101
  end
102
102
  end
@@ -29,10 +29,12 @@ module Metanorma
29
29
  def cleanup(xmldoc)
30
30
  @doctype = xmldoc.at("//bibdata/ext/doctype")&.text
31
31
  element_name_cleanup(xmldoc)
32
- passthrough_cleanup(xmldoc)
32
+ source_include_cleanup(xmldoc) # feeds: misccontainer_cleanup
33
+ passthrough_cleanup(xmldoc) # feeds: smartquotes_cleanup
33
34
  unnumbered_blocks_cleanup(xmldoc)
34
35
  termdocsource_cleanup(xmldoc) # feeds: metadata_cleanup
35
36
  metadata_cleanup(xmldoc) # feeds: boilerplate_cleanup
37
+ misccontainer_cleanup(xmldoc)
36
38
  sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup,
37
39
  # floatingtitle_cleanup
38
40
  obligations_cleanup(xmldoc)
@@ -89,10 +91,12 @@ module Metanorma
89
91
  linebreak_cleanup(xmldoc)
90
92
  variant_cleanup(xmldoc)
91
93
  para_cleanup(xmldoc)
94
+ source_id_cleanup(xmldoc)
92
95
  empty_element_cleanup(xmldoc)
93
96
  img_cleanup(xmldoc)
94
97
  anchor_cleanup(xmldoc)
95
98
  link_cleanup(xmldoc)
99
+ passthrough_metanorma_cleanup(xmldoc)
96
100
  xmldoc
97
101
  end
98
102
 
@@ -52,7 +52,7 @@ module Metanorma
52
52
  i = i.add_child("<references hidden='true' normative='false'/>").first
53
53
  refs.each do |x|
54
54
  i << <<~BIB
55
- <bibitem anchor="#{x}" id="_#{UUIDTools::UUID.random_create}" type="internal">
55
+ <bibitem anchor="#{x}" #{add_id_text} type="internal">
56
56
  <docidentifier type="repository">#{x.sub(/^#{prefix}_/, "#{prefix}/")}</docidentifier>
57
57
  </bibitem>
58
58
  BIB
@@ -174,7 +174,7 @@ module Metanorma
174
174
  @datauriattachment and
175
175
  f = File.join(@attachmentsdir, File.basename(path))
176
176
  Pathname.new(File.expand_path(f))
177
- .relative_path_from(Pathname.new(File.expand_path(@localdir))).to_s
177
+ .relative_path_from(Pathname.new(File.expand_path(@output_dir))).to_s
178
178
  end
179
179
 
180
180
  def datauri_attachment(path, doc)
@@ -182,7 +182,7 @@ module Metanorma
182
182
  m = add_misc_container(doc)
183
183
  f = attachment_location(path)
184
184
  e = (m << "<attachment name='#{f}'/>").last_element_child
185
- Vectory::Utils::datauri(path, @localdir).scan(/.{1,60}/)
185
+ Vectory::Utils::datauri(path, @output_dir).scan(/.{1,60}/)
186
186
  .each { |dd| e << "#{dd}\n" }
187
187
  f
188
188
  end
@@ -196,6 +196,7 @@ module Metanorma
196
196
  end
197
197
 
198
198
  def init_attachments
199
+ @datauriattachment or return
199
200
  @attachmentsdir and return
200
201
  @attachmentsfld = "_#{@filename}_attachments"
201
202
  @attachmentsdir = File.join(@output_dir, @attachmentsfld)
@@ -94,6 +94,7 @@ module Metanorma
94
94
  def footnote_block_cleanup(xmldoc)
95
95
  ids = xmldoc.xpath("//footnoteblock").each_with_object([]) do |f, m|
96
96
  f.name = "fn"
97
+ add_id(f)
97
98
  m << f.text
98
99
  if id = xmldoc.at("//*[@anchor = '#{f.text}']")
99
100
  f.children = id.dup.children
@@ -137,7 +137,6 @@ module Metanorma
137
137
 
138
138
  def contenthash_id_cleanup(doc)
139
139
  @contenthash_ids = contenthash_id_make(doc)
140
- #contenthash_id_update_idrefs(doc, @contenthash_ids)
141
140
  end
142
141
 
143
142
  def contenthash_id_make(doc)
@@ -150,14 +149,6 @@ module Metanorma
150
149
  end
151
150
  end
152
151
 
153
- def contenthash_id_update_idrefs(doc, ids)
154
- Metanorma::Utils::anchor_attributes.each do |a|
155
- doc.xpath("//#{a[0]}").each do |x|
156
- ids[x[a[1]]] and x[a[1]] = ids[x[a[1]]]
157
- end
158
- end
159
- end
160
-
161
152
  def contenthash(elem)
162
153
  Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
163
154
  .sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
@@ -168,14 +159,17 @@ module Metanorma
168
159
  p.name = "passthrough"
169
160
  p.children = select_odd_chars(p.children.to_xml)
170
161
  end
171
- doc.xpath("//passthrough[@format = 'metanorma']").each do |p|
172
- p.replace(p.children)
173
- end
174
162
  doc.xpath("//identifier").each do |p|
175
163
  p.children = select_odd_chars(p.children.to_xml)
176
164
  end
177
165
  end
178
166
 
167
+ def passthrough_metanorma_cleanup(doc)
168
+ doc.xpath("//passthrough[@formats = 'metanorma']").each do |p|
169
+ p.replace(p.children)
170
+ end
171
+ end
172
+
179
173
  def link_cleanup(xmldoc)
180
174
  uri_cleanup(xmldoc)
181
175
  end
@@ -193,6 +187,13 @@ module Metanorma
193
187
  CGI.escape(comp).gsub("+", "%20")
194
188
  end
195
189
 
190
+ def source_id_cleanup(xmldoc)
191
+ xmldoc.xpath("//span[normalize-space(.)=''][@source]").each do |s|
192
+ s.parent["source"] = s["source"]
193
+ s.remove
194
+ end
195
+ end
196
+
196
197
  private
197
198
 
198
199
  # skip ZWNJ inserted to prevent regexes operating in asciidoctor
@@ -124,7 +124,6 @@ module Metanorma
124
124
  end
125
125
 
126
126
  def sections_cleanup(xml)
127
- misccontainer_cleanup(xml)
128
127
  sections_order_cleanup(xml)
129
128
  sections_level_cleanup(xml)
130
129
  sections_names_cleanup(xml)
@@ -133,9 +132,32 @@ module Metanorma
133
132
  end
134
133
 
135
134
  def misccontainer_cleanup(xml)
136
- m = xml.at("//misc-container-clause") or return
135
+ m = xml.xpath("//metanorma-extension-clause")
136
+ m.empty? and return
137
137
  ins = add_misc_container(xml)
138
- ins << m.remove.children
138
+ m.each do |m1|
139
+ ins << m1.remove.children
140
+ end
141
+ end
142
+
143
+ def source_include_cleanup(xml)
144
+ xml.xpath("//source-include").each do |s|
145
+ f = File.join(@localdir, s["path"])
146
+ s.remove
147
+ r = source_sanitise(File.read(f))
148
+ xml.root << <<~XML
149
+ <metanorma-extension-clause>
150
+ <clause>
151
+ <title #{add_id_text}>#{s['path']}</title>
152
+ <source>#{r} </source>
153
+ </clause>
154
+ </metanorma-extension-clause>
155
+ XML
156
+ end
157
+ end
158
+
159
+ def source_sanitise(code)
160
+ code
139
161
  end
140
162
 
141
163
  def single_clause_annex(xml)
@@ -9,7 +9,9 @@ module Metanorma
9
9
  node.children.first.previous = "<title/>"
10
10
  end
11
11
  end
12
- node.at("./title")
12
+ ret = node.at("./title")
13
+ add_id(ret)
14
+ ret
13
15
  end
14
16
 
15
17
  def replace_title(doc, xpath, text, first = false)
@@ -149,7 +151,6 @@ module Metanorma
149
151
  path = section_containers.map { |x| "./ancestor::#{x}" }.join(" | ")
150
152
  xml.xpath("//p[@variant_title]").each do |p|
151
153
  p.name = "variant-title"
152
- p.delete("id")
153
154
  p.delete("variant_title")
154
155
  p.xpath("(#{path})[last()]").each do |sect|
155
156
  (ins = sect.at("./title") and ins.next = p) or
@@ -34,6 +34,7 @@ module Metanorma
34
34
  xmldoc.xpath("//term[not(definition)]").each do |d|
35
35
  first_child = d.at(TERMDEF_BLOCKS) || next
36
36
  t = Nokogiri::XML::Element.new("definition", xmldoc)
37
+ add_id(t)
37
38
  first_child.replace(t)
38
39
  t << first_child.remove
39
40
  d.xpath(TERMDEF_BLOCKS).each do |n|
@@ -45,10 +46,13 @@ module Metanorma
45
46
  def split_termdefinitions(xmldoc)
46
47
  xmldoc.xpath("//definition").each do |d|
47
48
  if d.at("./p | ./ol | ./dl | ./ul")
48
- d.children = "<verbal-definition>#{d.children}</verbal-definition>"
49
+ d.children = <<~XML.strip
50
+ <verbal-definition #{add_id_text}>#{d.children}</verbal-definition>
51
+ XML
49
52
  else
50
- d.children = "<non-verbal-representation>" \
51
- "#{d.children}</non-verbal-representation>"
53
+ d.children = <<~XML.strip
54
+ <non-verbal-representation #{add_id_text}>#{d.children}</non-verbal-representation>
55
+ XML
52
56
  end
53
57
  end
54
58
  end
@@ -124,9 +128,16 @@ module Metanorma
124
128
  termdefinition_cleanup(xmldoc)
125
129
  termdomain1_cleanup(xmldoc)
126
130
  termnote_example_cleanup(xmldoc)
131
+ term_id_attr_cleanup(xmldoc)
127
132
  term_children_cleanup(xmldoc)
128
133
  end
129
134
 
135
+ def term_id_attr_cleanup(xmldoc)
136
+ xmldoc.xpath("//usage-info[@id]").each do |u|
137
+ u.delete("id")
138
+ end
139
+ end
140
+
130
141
  def term_index_cleanup(xmldoc)
131
142
  @index_terms or return
132
143
  xmldoc.xpath("//preferred").each do |p|
@@ -32,19 +32,21 @@ module Metanorma
32
32
  e[:skip] and next
33
33
  lines = lines_strip_textspan(e, block[i + 1])
34
34
  out = Metanorma::Utils.line_sanitise(lines)
35
- # e[:last] or out.pop
35
+ e[:last] or out.pop
36
+ /\s$/.match?(e[:text][-1]) or out[-1].rstrip!
36
37
  e[:elem].replace(out.join)
37
38
  end
38
39
  end
39
40
 
40
- def lines_strip_textspan(span, _nextspan)
41
+ def lines_strip_textspan(span, nextspan)
41
42
  lines = span[:text].lines[0..-2].map(&:rstrip) <<
42
43
  span[:text].lines[-1]&.sub(/\n$/, "")
43
44
  # no final line rstrip: can be space linking to next line
44
- # span[:last] or lines << nextspan[:text].lines.first # next token context
45
+ span[:last] or lines << nextspan[:text].lines.first # next token context
45
46
  lines
46
47
  end
47
48
 
49
+ # TODO: we are not counting empty xref, eref here
48
50
  def gather_text_for_linebreak_cleanup(block)
49
51
  x = block.xpath(".//text()").map do |e|
50
52
  { elem: e, text: e.text, stem: ancestor_include?(e, %w(stem)),
@@ -35,11 +35,12 @@ module Metanorma
35
35
  block_macro Metanorma::Plugin::Lutaml::LutamlKlassTableBlockMacro
36
36
  preprocessor Metanorma::Standoc::EmbedIncludeProcessor
37
37
  preprocessor Metanorma::Standoc::LinkProtectPreprocessor
38
+ preprocessor Metanorma::Standoc::PassProtectPreprocessor
38
39
  preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
39
40
  preprocessor Metanorma::Standoc::Datamodel::DiagramPreprocessor
40
- preprocessor Metanorma::Plugin::Datastruct::Json2TextPreprocessor
41
- preprocessor Metanorma::Plugin::Datastruct::Yaml2TextPreprocessor
42
- preprocessor Metanorma::Plugin::Datastruct::Data2TextPreprocessor
41
+ preprocessor Metanorma::Plugin::Lutaml::Json2TextPreprocessor
42
+ preprocessor Metanorma::Plugin::Lutaml::Yaml2TextPreprocessor
43
+ preprocessor Metanorma::Plugin::Lutaml::Data2TextPreprocessor
43
44
  preprocessor Metanorma::Plugin::Glossarist::DatasetPreprocessor
44
45
  preprocessor Metanorma::Standoc::NamedEscapePreprocessor
45
46
  inline_macro Metanorma::Standoc::PreferredTermInlineMacro
@@ -69,11 +70,14 @@ module Metanorma
69
70
  inline_macro Metanorma::Standoc::FormSelectMacro
70
71
  inline_macro Metanorma::Standoc::FormOptionMacro
71
72
  inline_macro Metanorma::Standoc::ToCInlineMacro
72
- inline_macro Metanorma::Standoc::PassInlineMacro
73
+ inline_macro Metanorma::Standoc::PassFormatInlineMacro
73
74
  inline_macro Metanorma::Standoc::StdLinkInlineMacro
74
75
  inline_macro Metanorma::Standoc::NumberInlineMacro
75
76
  inline_macro Metanorma::Standoc::TrStyleInlineMacro
76
77
  inline_macro Metanorma::Standoc::TdStyleInlineMacro
78
+ inline_macro Metanorma::Standoc::AnchorInlineMacro
79
+ inline_macro Metanorma::Standoc::SourceIdInlineMacro
80
+ inline_macro Metanorma::Standoc::SourceIncludeInlineMacro
77
81
  block Metanorma::Standoc::ToDoAdmonitionBlock
78
82
  block Metanorma::Standoc::EditorAdmonitionBlock
79
83
  treeprocessor Metanorma::Standoc::EditorInlineAdmonitionBlock
@@ -103,15 +107,20 @@ module Metanorma
103
107
  $xreftext = {}
104
108
 
105
109
  def initialize(backend, opts)
110
+ doc = opts&.dig(:document)
111
+ doc&.delete_attribute("sectids") # no autoassign sect ids from title
106
112
  super
107
113
  basebackend "html"
108
114
  outfilesuffix ".xml"
109
115
  @libdir = File.dirname(self.class::_file || __FILE__)
110
116
  @c = HTMLEntities.new
111
- unless opts && @log = opts[:document]&.options&.dig(:log)
112
- @log = Metanorma::Utils::Log.new
113
- @local_log = true
114
- end
117
+ local_log(doc)
118
+ end
119
+
120
+ def local_log(doc)
121
+ @log = doc&.options&.dig(:log) and return
122
+ @log = Metanorma::Utils::Log.new
123
+ @local_log = true
115
124
  end
116
125
 
117
126
  class << self
@@ -105,14 +105,20 @@ module Metanorma
105
105
  @output_dir = outputdir node
106
106
  end
107
107
 
108
+ def i18nyaml_path(node)
109
+ if i18nyaml = node.attr("i18nyaml")
110
+ (Pathname.new i18nyaml).absolute? or
111
+ i18nyaml = File.join(@localdir, i18nyaml)
112
+ end
113
+ i18nyaml
114
+ end
115
+
108
116
  def init_i18n(node)
109
117
  @lang = node.attr("language") || "en"
110
118
  @script = node.attr("script") ||
111
119
  Metanorma::Utils.default_script(node.attr("language"))
112
120
  @locale = node.attr("locale")
113
- i18nyaml = node.attr("i18nyaml")
114
- i18nyaml &&= File.join(@localdir, i18nyaml)
115
- @isodoc = isodoc(@lang, @script, @locale, i18nyaml)
121
+ @isodoc = isodoc(@lang, @script, @locale, i18nyaml_path(node))
116
122
  @i18n = @isodoc.i18n
117
123
  end
118
124
 
@@ -13,6 +13,11 @@ module Metanorma
13
13
  end
14
14
  end
15
15
 
16
+ def pass(node)
17
+ require "debug"; binding.b
18
+ "<passthrough-inline formats='metanorma'>#{node.content}</passthrough-inline>"
19
+ end
20
+
16
21
  def page_break(node)
17
22
  attrs = {}
18
23
  node.option?("landscape") and attrs[:orientation] = "landscape"
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- VERSION v2.0.5 -->
3
+ <!-- VERSION v2.0.7 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -76,6 +76,7 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
76
76
  <a:documentation>Title(s) of a clause</a:documentation>
77
77
  <element name="title">
78
78
  <a:documentation>Title proper for a clause</a:documentation>
79
+ <ref name="RequiredId"/>
79
80
  <zeroOrMore>
80
81
  <ref name="TextElement"/>
81
82
  </zeroOrMore>
@@ -83,10 +84,19 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
83
84
  <zeroOrMore>
84
85
  <element name="variant-title">
85
86
  <a:documentation>Alternate title for a clause</a:documentation>
87
+ <ref name="RequiredId"/>
86
88
  <ref name="TypedTitleString"/>
87
89
  </element>
88
90
  </zeroOrMore>
89
91
  </define>
92
+ <define name="tname">
93
+ <element name="name">
94
+ <ref name="RequiredId"/>
95
+ <oneOrMore>
96
+ <ref name="NestedTextElement"/>
97
+ </oneOrMore>
98
+ </element>
99
+ </define>
90
100
  <define name="UlBody">
91
101
  <optional>
92
102
  <ref name="tname">
@@ -475,6 +485,7 @@ normative or informative references, some split references into sections organiz
475
485
  <!-- exclude figures? -->
476
486
  <define name="dd">
477
487
  <element name="dd">
488
+ <ref name="OptionalId"/>
478
489
  <zeroOrMore>
479
490
  <!-- exclude figures? -->
480
491
  <ref name="BasicBlock"/>
@@ -526,6 +537,7 @@ normative or informative references, some split references into sections organiz
526
537
  </choice>
527
538
  </define>
528
539
  <define name="TrAttributes">
540
+ <ref name="OptionalId"/>
529
541
  <optional>
530
542
  <attribute name="style">
531
543
  <a:documentation>CSS style: only background-color supported</a:documentation>
@@ -595,6 +607,7 @@ gives an explicit page orientation</a:documentation>
595
607
  </include>
596
608
  <!-- end overrides -->
597
609
  <define name="FnAttributes" combine="interleave">
610
+ <ref name="RequiredId"/>
598
611
  <optional>
599
612
  <attribute name="hiddenref">
600
613
  <a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
@@ -604,6 +617,7 @@ This is done if the footnote reference is already presented in some other form,
604
617
  </optional>
605
618
  </define>
606
619
  <define name="TdAttributes" combine="interleave">
620
+ <ref name="RequiredId"/>
607
621
  <optional>
608
622
  <attribute name="style">
609
623
  <a:documentation>CSS style: only background-color supported</a:documentation>
@@ -801,6 +815,12 @@ titlecase, or lowercase</a:documentation>
801
815
  <a:documentation>User-supplied anchor of element; replaced by content-based id, with all references to the anchor updated accordingly</a:documentation>
802
816
  </attribute>
803
817
  </optional>
818
+ <optional>
819
+ <attribute name="source">
820
+ <a:documentation>Sourcing of the current element in an external data model</a:documentation>
821
+ <ref name="IdRefType"/>
822
+ </attribute>
823
+ </optional>
804
824
  </define>
805
825
  <define name="OptionalId" combine="interleave">
806
826
  <optional>
@@ -808,6 +828,12 @@ titlecase, or lowercase</a:documentation>
808
828
  <a:documentation> User-supplied anchor of element; replaced by content-based id, with all references to the anchor updated accordingly</a:documentation>
809
829
  </attribute>
810
830
  </optional>
831
+ <optional>
832
+ <attribute name="source">
833
+ <a:documentation>Sourcing of the current element in an external data model</a:documentation>
834
+ <ref name="IdRefType"/>
835
+ </attribute>
836
+ </optional>
811
837
  </define>
812
838
  <define name="ObligationType">
813
839
  <a:documentation>The force of a clause in a standard document: whether it has normative or informative effect</a:documentation>
@@ -954,6 +980,7 @@ titlecase, or lowercase</a:documentation>
954
980
  is used in particular to capture mutually agreed definitions of codepoints in Unicode Private Use Area</a:documentation>
955
981
  </attribute>
956
982
  </optional>
983
+ <ref name="OptionalId"/>
957
984
  <oneOrMore>
958
985
  <ref name="TextElement">
959
986
  <a:documentation>Textual content of span</a:documentation>
@@ -1808,7 +1835,7 @@ used in document amendments</a:documentation>
1808
1835
  </element>
1809
1836
  </define>
1810
1837
  <define name="TermAttributes">
1811
- <ref name="OptionalId"/>
1838
+ <ref name="RequiredId"/>
1812
1839
  <ref name="LocalizedStringAttributes"/>
1813
1840
  <ref name="BlockAttributes"/>
1814
1841
  </define>
@@ -2151,6 +2178,7 @@ used in document amendments</a:documentation>
2151
2178
  <define name="termdefinition">
2152
2179
  <a:documentation>The definition of a term applied in the current document</a:documentation>
2153
2180
  <element name="definition">
2181
+ <ref name="RequiredId"/>
2154
2182
  <optional>
2155
2183
  <attribute name="type">
2156
2184
  <a:documentation>Type of definition, used to differentiate it from other definitions of the same term if present</a:documentation>
@@ -2172,6 +2200,7 @@ used in document amendments</a:documentation>
2172
2200
  </define>
2173
2201
  <define name="verbaldefinition">
2174
2202
  <element name="verbal-definition">
2203
+ <ref name="RequiredId"/>
2175
2204
  <oneOrMore>
2176
2205
  <choice>
2177
2206
  <a:documentation>Content of the verbal representation of the term</a:documentation>
@@ -2192,6 +2221,7 @@ used in document amendments</a:documentation>
2192
2221
  <define name="nonverbalrep">
2193
2222
  <a:documentation>Non-verbal representation of the term</a:documentation>
2194
2223
  <element name="non-verbal-representation">
2224
+ <ref name="RequiredId"/>
2195
2225
  <oneOrMore>
2196
2226
  <choice>
2197
2227
  <a:documentation>Content of the non-verbal representation of the term</a:documentation>
@@ -85,7 +85,7 @@ module Metanorma
85
85
  xml_dl.dd
86
86
  return
87
87
  end
88
- xml_dl.dd do |xml_dd|
88
+ xml_dl.dd **dl_attrs(ddefn) do |xml_dd|
89
89
  xml_dd.p { |t| t << ddefn.text } if ddefn.text?
90
90
  xml_dd << ddefn.content if ddefn.blocks?
91
91
  end
@@ -122,7 +122,7 @@ module Metanorma
122
122
  end
123
123
 
124
124
  def list_caption(node, out)
125
- a = node.title and out.name { |n| n << a }
125
+ block_title(node, out)
126
126
  end
127
127
  end
128
128
  end