metanorma-standoc 2.1.1 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +3 -1
  3. data/lib/metanorma/standoc/biblio.rng +134 -39
  4. data/lib/metanorma/standoc/blocks.rb +8 -6
  5. data/lib/metanorma/standoc/blocks_notes.rb +4 -1
  6. data/lib/metanorma/standoc/cleanup.rb +1 -0
  7. data/lib/metanorma/standoc/cleanup_footnotes.rb +32 -25
  8. data/lib/metanorma/standoc/cleanup_inline.rb +17 -0
  9. data/lib/metanorma/standoc/cleanup_ref.rb +16 -0
  10. data/lib/metanorma/standoc/cleanup_section.rb +6 -0
  11. data/lib/metanorma/standoc/cleanup_terms.rb +3 -1
  12. data/lib/metanorma/standoc/cleanup_text.rb +9 -4
  13. data/lib/metanorma/standoc/cleanup_xref.rb +2 -1
  14. data/lib/metanorma/standoc/converter.rb +4 -0
  15. data/lib/metanorma/standoc/isodoc.rng +32 -0
  16. data/lib/metanorma/standoc/lists.rb +8 -3
  17. data/lib/metanorma/standoc/macros.rb +28 -1
  18. data/lib/metanorma/standoc/macros_note.rb +27 -6
  19. data/lib/metanorma/standoc/ref.rb +3 -1
  20. data/lib/metanorma/standoc/ref_sect.rb +5 -2
  21. data/lib/metanorma/standoc/ref_utility.rb +20 -5
  22. data/lib/metanorma/standoc/section.rb +1 -1
  23. data/lib/metanorma/standoc/version.rb +1 -1
  24. data/metanorma-standoc.gemspec +2 -2
  25. data/spec/examples/datamodel/address_class_profile.presentation.xml +14 -0
  26. data/spec/metanorma/base_spec.rb +41 -5
  27. data/spec/metanorma/blocks_spec.rb +58 -1
  28. data/spec/metanorma/cleanup_sections_spec.rb +60 -9
  29. data/spec/metanorma/cleanup_spec.rb +6 -6
  30. data/spec/metanorma/cleanup_terms_spec.rb +1 -1
  31. data/spec/metanorma/inline_spec.rb +3 -3
  32. data/spec/metanorma/lists_spec.rb +10 -4
  33. data/spec/metanorma/macros_spec.rb +50 -15
  34. data/spec/metanorma/refs_dl_spec.rb +18 -7
  35. data/spec/metanorma/refs_spec.rb +390 -450
  36. data/spec/metanorma/table_spec.rb +24 -6
  37. data/spec/spec_helper.rb +2 -2
  38. data/spec/vcr_cassettes/bsi16341.yml +57 -71
  39. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +67 -67
  40. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +14 -14
  41. data/spec/vcr_cassettes/hide_refs.yml +62 -62
  42. data/spec/vcr_cassettes/isobib_get_123.yml +14 -14
  43. data/spec/vcr_cassettes/isobib_get_123_1.yml +26 -26
  44. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +37 -37
  45. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -14
  46. data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
  47. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +228 -52
  48. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +47 -49
  49. data/spec/vcr_cassettes/std-link.yml +15 -15
  50. metadata +10 -10
  51. data/docs/quickstart.adoc +0 -375
@@ -38,9 +38,8 @@ module Metanorma
38
38
 
39
39
  noko do |xml|
40
40
  xml.ul **ul_attrs(node) do |xml_ul|
41
- node.items.each do |item|
42
- ul_li(xml_ul, item)
43
- end
41
+ list_caption(node, xml_ul)
42
+ node.items.each { |item| ul_li(xml_ul, item) }
44
43
  end
45
44
  end.join("\n")
46
45
  end
@@ -62,6 +61,7 @@ module Metanorma
62
61
  def olist(node)
63
62
  noko do |xml|
64
63
  xml.ol **ol_attrs(node) do |xml_ol|
64
+ list_caption(node, xml_ol)
65
65
  node.items.each { |item| li(xml_ol, item) }
66
66
  end
67
67
  end.join("\n")
@@ -98,6 +98,7 @@ module Metanorma
98
98
  def dlist(node)
99
99
  noko do |xml|
100
100
  xml.dl **dl_attrs(node) do |xml_dl|
101
+ list_caption(node, xml_dl)
101
102
  node.items.each do |terms, dd|
102
103
  dt(terms, xml_dl)
103
104
  dd(dd, xml_dl)
@@ -115,6 +116,10 @@ module Metanorma
115
116
  end
116
117
  end.join("\n")
117
118
  end
119
+
120
+ def list_caption(node, out)
121
+ a = node.title and out.name { |n| n << a }
122
+ end
118
123
  end
119
124
  end
120
125
  end
@@ -191,6 +191,7 @@ module Metanorma
191
191
  end
192
192
  end
193
193
 
194
+ # inject ZWNJ to prevent Asciidoctor from attempting regex substitutions
194
195
  class PassInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
195
196
  use_dsl
196
197
  named :"pass-format"
@@ -198,7 +199,21 @@ module Metanorma
198
199
  def process(parent, target, attrs)
199
200
  format = target || "metanorma"
200
201
  out = Asciidoctor::Inline.new(parent, :quoted, attrs[1]).convert
201
- %{<passthrough formats="#{format}">#{out}</passthrough>}
202
+ .gsub(/((?![<>&])[[:punct:]])/, "\\1&#x200c;")
203
+ %{<passthrough-inline formats="#{format}">#{out}</passthrough-inline>}
204
+ end
205
+ end
206
+
207
+ class IdentifierInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
208
+ use_dsl
209
+ named :identifier
210
+ parse_content_as :raw
211
+ using_format :short
212
+
213
+ def process(parent, _target, attrs)
214
+ out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
215
+ .gsub(/((?![<>&])[[:punct:]])/, "\\1&#x200c;")
216
+ %{<identifier>#{out}</identifier>}
202
217
  end
203
218
  end
204
219
 
@@ -213,5 +228,17 @@ module Metanorma
213
228
  type: :xref, target: "_#{UUIDTools::UUID.random_create}")
214
229
  end
215
230
  end
231
+
232
+ class NamedEscapePreprocessor < Asciidoctor::Extensions::Preprocessor
233
+ def process(_document, reader)
234
+ c = HTMLEntities.new
235
+ lines = reader.readlines.map do |l|
236
+ l.split(/(&[A-Za-z][^;]*;)/).map do |s|
237
+ /^&[A-Za-z]/.match?(s) ? c.encode(c.decode(s), :hexadecimal) : s
238
+ end.join
239
+ end
240
+ ::Asciidoctor::Reader.new lines
241
+ end
242
+ end
216
243
  end
217
244
  end
@@ -18,15 +18,10 @@ module Metanorma
18
18
  (document.find_by context: :paragraph).each do |para|
19
19
  next unless /^TODO: /.match? para.lines[0]
20
20
 
21
- parent = para.parent
22
21
  para.set_attr("name", "todo")
23
22
  para.set_attr("caption", "TODO")
24
23
  para.lines[0].sub!(/^TODO: /, "")
25
- todo = Asciidoctor::Block
26
- .new(parent, :admonition, attributes: para.attributes,
27
- source: para.lines,
28
- content_model: :compound)
29
- parent.blocks[parent.blocks.index(para)] = todo
24
+ para.context = :admonition
30
25
  end
31
26
  end
32
27
  end
@@ -42,5 +37,31 @@ module Metanorma
42
37
  %{<footnoteblock>#{out}</footnoteblock>}
43
38
  end
44
39
  end
40
+
41
+ class EditorAdmonitionBlock < Asciidoctor::Extensions::BlockProcessor
42
+ use_dsl
43
+ named :EDITOR
44
+ on_contexts :example, :paragraph
45
+
46
+ def process(parent, reader, attrs)
47
+ attrs["name"] = "editorial"
48
+ attrs["caption"] = "EDITOR"
49
+ create_block(parent, :admonition, reader.lines, attrs,
50
+ content_model: :compound)
51
+ end
52
+ end
53
+
54
+ class EditorInlineAdmonitionBlock < Asciidoctor::Extensions::Treeprocessor
55
+ def process(document)
56
+ (document.find_by context: :paragraph).each do |para|
57
+ next unless /^EDITOR: /.match? para.lines[0]
58
+
59
+ para.set_attr("name", "editorial")
60
+ para.set_attr("caption", "EDITOR")
61
+ para.lines[0].sub!(/^EDITOR: /, "")
62
+ para.context = :admonition
63
+ end
64
+ end
65
+ end
45
66
  end
46
67
  end
@@ -82,7 +82,8 @@ module Metanorma
82
82
  def isorefmatches3out(item, xml)
83
83
  if item[:doc] then use_retrieved_relaton(item, xml)
84
84
  else
85
- isorefmatches3_1(xml, item[:ref][:match], item[:ref][:yr],
85
+ isorefmatches3_1(xml, item[:ref][:match],
86
+ item[:ref][:yr],
86
87
  item[:ref][:hasyr], item[:doc])
87
88
  end
88
89
  end
@@ -117,6 +118,7 @@ module Metanorma
117
118
 
118
119
  def refitem_render(xml, match, code)
119
120
  xml.bibitem **attr_code(id: match[:anchor],
121
+ suppress_identifier: code[:dropid],
120
122
  hidden: code[:hidden]) do |t|
121
123
  t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
122
124
  i << ref_normalise_no_format(match[:text])
@@ -84,7 +84,8 @@ module Metanorma
84
84
  if ref[:code].nil? || ref[:no_year] || @bibdb.nil?
85
85
  res << [ref, idx, nil]
86
86
  else
87
- @bibdb.fetch_async(ref[:code], ref[:year], ref) do |doc|
87
+ @bibdb.fetch_async(HTMLEntities.new.decode(ref[:code]),
88
+ ref[:year], ref) do |doc|
88
89
  res << [ref, idx, doc]
89
90
  end
90
91
  end
@@ -119,7 +120,9 @@ module Metanorma
119
120
  def use_retrieved_relaton(item, xml)
120
121
  xml.parent.add_child(smart_render_xml(item[:doc], item[:ref][:code],
121
122
  item[:ref]))
122
- use_my_anchor(xml, item[:ref][:match][:anchor], item.dig(:ref, :analyse_code, :hidden))
123
+ use_my_anchor(xml, item[:ref][:match][:anchor],
124
+ hidden: item.dig(:ref, :analyse_code, :hidden),
125
+ dropid: item.dig(:ref, :analyse_code, :dropid))
123
126
  end
124
127
 
125
128
  def init_bib_caches(node)
@@ -31,9 +31,11 @@ module Metanorma
31
31
  end
32
32
  end
33
33
 
34
- def use_my_anchor(ref, id, hidden)
34
+ def use_my_anchor(ref, id, opt)
35
35
  ref.parent.elements.last["id"] = id
36
- hidden and ref.parent.elements.last["hidden"] = hidden
36
+ opt[:hidden] and ref.parent.elements.last["hidden"] = opt[:hidden]
37
+ opt[:dropid] and
38
+ ref.parent.elements.last["suppress_identifier"] = opt[:dropid]
37
39
  ref
38
40
  end
39
41
 
@@ -57,6 +59,7 @@ module Metanorma
57
59
 
58
60
  def mn_code(code)
59
61
  code.sub(/^\(/, "[").sub(/\).*$/, "]")
62
+ .sub(/^dropid\((.+)\)$/, "\\1")
60
63
  .sub(/^hidden\((.+)\)$/, "\\1")
61
64
  .sub(/^nofetch\((.+)\)$/, "\\1")
62
65
  end
@@ -73,6 +76,12 @@ module Metanorma
73
76
  ret.merge(id: m[:id], hidden: true)
74
77
  end
75
78
 
79
+ def analyse_ref_dropid(ret)
80
+ return ret unless m = /^dropid\((?<id>.+)\)$/.match(ret[:id])
81
+
82
+ ret.merge(id: m[:id], dropid: true)
83
+ end
84
+
76
85
  def analyse_ref_repo_path(ret)
77
86
  return ret unless m =
78
87
  /^(?<type>repo|path):\((?<key>[^,]+),?(?<id>.*)\)$/
@@ -89,14 +98,16 @@ module Metanorma
89
98
  end
90
99
 
91
100
  # ref id = (usrlbl)code[:-]year
92
- # code = nofetch(code) | hidden(code) | (repo|path):(key,code) |
101
+ # code = nofetch(code) | hidden(code) | dropid(code) | (repo|path):(key,code) |
93
102
  # \[? number \]? | ident
94
103
  def analyse_ref_code(code)
95
104
  ret = { id: code }
96
105
  return ret if code.blank?
97
106
 
98
107
  analyse_ref_nofetch(
99
- analyse_ref_hidden(analyse_ref_repo_path(analyse_ref_numeric(ret))),
108
+ analyse_ref_hidden(
109
+ analyse_ref_dropid(analyse_ref_repo_path(analyse_ref_numeric(ret))),
110
+ ),
100
111
  )
101
112
  end
102
113
 
@@ -110,7 +121,11 @@ module Metanorma
110
121
  end
111
122
 
112
123
  def ref_attributes(match)
113
- { id: match[:anchor], type: "standard" }
124
+
125
+ code = analyse_ref_code(match[:code])
126
+
127
+ { id: match[:anchor], type: "standard",
128
+ suppress_identifier: code[:dropid] || nil }
114
129
  end
115
130
 
116
131
  MALFORMED_REF = <<~REF.freeze
@@ -152,7 +152,7 @@ module Metanorma
152
152
  attrs[:bibitem] = true if node.option? "bibitem"
153
153
  attrs[:level] = node.attr("level")
154
154
  set_obligation(attrs, node)
155
- xml.send "clause", **attr_code(attrs) do |xml_section|
155
+ xml.send :clause, **attr_code(attrs) do |xml_section|
156
156
  xml_section.title { |n| n << node.title } unless node.title.nil?
157
157
  xml_section << node.content
158
158
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.1.1".freeze
22
+ VERSION = "2.1.4".freeze
23
23
  end
24
24
  end
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency "latexmath"
39
39
  spec.add_dependency "mathml2asciimath"
40
40
  spec.add_dependency "metanorma-utils", "~> 1.2.8"
41
- spec.add_dependency "relaton-cli", "~> 1.9.0"
41
+ spec.add_dependency "relaton-cli", "~> 1.12.0"
42
42
  spec.add_dependency "relaton-iev", "~> 1.1.0"
43
43
  spec.add_dependency "unicode2latex", "~> 0.0.1"
44
44
 
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
47
47
  spec.add_development_dependency "guard", "~> 2.14"
48
48
  spec.add_development_dependency "guard-rspec", "~> 4.7"
49
- spec.add_development_dependency "metanorma-iso"
49
+ spec.add_development_dependency "metanorma-iso", "~>2.1.2"
50
50
  spec.add_development_dependency "rake", "~> 13.0"
51
51
  spec.add_development_dependency "rspec", "~> 3.6"
52
52
  spec.add_development_dependency "rubocop", "~> 1.5.2"
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="presentation" version="2.0.4">
3
+ <bibdata type="standard">
4
+ <title language="en" format="text/plain">Document title</title>
5
+ <language current="true">en</language><script current="true">Latn</script><status><stage language="">published</stage></status><copyright><from>2022</from></copyright><ext><doctype language="">article</doctype></ext></bibdata><localized-strings><localized-string key="scope" language="en">Scope</localized-string><localized-string key="symbolsabbrev" language="en">Symbols and abbreviated terms</localized-string><localized-string key="abbrev" language="en">Abbreviated terms</localized-string><localized-string key="symbols" language="en">Symbols</localized-string><localized-string key="table_of_contents" language="en">Table of contents</localized-string><localized-string key="introduction" language="en">Introduction</localized-string><localized-string key="foreword" language="en">Foreword</localized-string><localized-string key="abstract" language="en">Abstract</localized-string><localized-string key="acknowledgements" language="en">Acknowledgements</localized-string><localized-string key="termsdef" language="en">Terms and definitions</localized-string><localized-string key="termsdefsymbolsabbrev" language="en">Terms, definitions, symbols and abbreviated terms</localized-string><localized-string key="termsdefsymbols" language="en">Terms, definitions and symbols</localized-string><localized-string key="termsdefabbrev" language="en">Terms, definitions and abbreviated terms</localized-string><localized-string key="normref" language="en">Normative references</localized-string><localized-string key="bibliography" language="en">Bibliography</localized-string><localized-string key="preface" language="en">Preface</localized-string><localized-string key="clause" language="en">Clause</localized-string><localized-string key="annex" language="en">Annex</localized-string><localized-string key="appendix" language="en">Appendix</localized-string><localized-string key="no_terms_boilerplate" language="en"><p>No terms and definitions are listed in this document.</p>
6
+ </localized-string><localized-string key="internal_terms_boilerplate" language="en"><p>For the purposes of this document,
7
+ the following terms and definitions apply.</p>
8
+ </localized-string><localized-string key="norm_with_refs_pref" language="en">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</localized-string><localized-string key="norm_empty_pref" language="en">There are no normative references in this document.</localized-string><localized-string key="external_terms_boilerplate" language="en"><p>For the purposes of this document,
9
+ the terms and definitions given in % apply.</p>
10
+ </localized-string><localized-string key="internal_external_terms_boilerplate" language="en"><p>For the purposes of this document, the terms and definitions
11
+ given in % and the following apply.</p>
12
+ </localized-string><localized-string key="term_defined_in" language="en">[term defined in %]</localized-string><localized-string key="binary_and" language="en">%1 and %2</localized-string><localized-string key="multiple_and" language="en">%1, and %2</localized-string><localized-string key="binary_or" language="en">%1 or %2</localized-string><localized-string key="multiple_or" language="en">%1, or %2</localized-string><localized-string key="chain_and" language="en">%1 and %2</localized-string><localized-string key="chain_or" language="en">%1 or %2</localized-string><localized-string key="chain_from" language="en">%1 from %2</localized-string><localized-string key="chain_to" language="en">%1 to %2</localized-string><localized-string key="note" language="en">NOTE</localized-string><localized-string key="note_xref" language="en">Note</localized-string><localized-string key="termnote" language="en">Note % to entry</localized-string><localized-string key="list" language="en">List</localized-string><localized-string key="deflist" language="en">Definition List</localized-string><localized-string key="figure" language="en">Figure</localized-string><localized-string key="formula" language="en">Formula</localized-string><localized-string key="inequality" language="en">Formula</localized-string><localized-string key="table" language="en">Table</localized-string><localized-string key="requirement" language="en">Requirement</localized-string><localized-string key="recommendation" language="en">Recommendation</localized-string><localized-string key="permission" language="en">Permission</localized-string><localized-string key="key" language="en">Key</localized-string><localized-string key="example" language="en">EXAMPLE</localized-string><localized-string key="example_xref" language="en">Example</localized-string><localized-string key="where" language="en">where</localized-string><localized-string key="wholeoftext" language="en">Whole of text</localized-string><localized-string key="draft_label" language="en">draft</localized-string><localized-string key="inform_annex" language="en">informative</localized-string><localized-string key="norm_annex" language="en">normative</localized-string><localized-string key="modified" language="en">modified</localized-string><localized-string key="deprecated" language="en">DEPRECATED</localized-string><localized-string key="source" language="en">SOURCE</localized-string><localized-string key="and" language="en">and</localized-string><localized-string key="all_parts" language="en">All Parts</localized-string><localized-string key="toc_figures" language="en">List of figures</localized-string><localized-string key="toc_tables" language="en">List of tables</localized-string><localized-string key="toc_recommendations" language="en">List of recommendations</localized-string><localized-string key="month_january" language="en">January</localized-string><localized-string key="month_february" language="en">February</localized-string><localized-string key="month_march" language="en">March</localized-string><localized-string key="month_april" language="en">April</localized-string><localized-string key="month_may" language="en">May</localized-string><localized-string key="month_june" language="en">June</localized-string><localized-string key="month_july" language="en">July</localized-string><localized-string key="month_august" language="en">August</localized-string><localized-string key="month_september" language="en">September</localized-string><localized-string key="month_october" language="en">October</localized-string><localized-string key="month_november" language="en">November</localized-string><localized-string key="month_december" language="en">December</localized-string><localized-string key="obligation" language="en">Obligation</localized-string><localized-string key="subject" language="en">Subject</localized-string><localized-string key="inherits" language="en">Inherits</localized-string><localized-string key="admonition.danger" language="en">Danger</localized-string><localized-string key="admonition.warning" language="en">Warning</localized-string><localized-string key="admonition.caution" language="en">Caution</localized-string><localized-string key="admonition.important" language="en">Important</localized-string><localized-string key="admonition.safety_precautions" language="en">Safety Precautions</localized-string><localized-string key="locality.section" language="en">Section</localized-string><localized-string key="locality.clause" language="en">Clause</localized-string><localized-string key="locality.part" language="en">Part</localized-string><localized-string key="locality.paragraph" language="en">Paragraph</localized-string><localized-string key="locality.chapter" language="en">Chapter</localized-string><localized-string key="locality.page" language="en">Page</localized-string><localized-string key="locality.table" language="en">Table</localized-string><localized-string key="locality.annex" language="en">Annex</localized-string><localized-string key="locality.figure" language="en">Figure</localized-string><localized-string key="locality.example" language="en">Example</localized-string><localized-string key="locality.note" language="en">Note</localized-string><localized-string key="locality.formula" language="en">Formula</localized-string><localized-string key="grammar_abbrevs.masculine" language="en">m</localized-string><localized-string key="grammar_abbrevs.feminine" language="en">f</localized-string><localized-string key="grammar_abbrevs.neuter" language="en">n</localized-string><localized-string key="grammar_abbrevs.common" language="en">common</localized-string><localized-string key="grammar_abbrevs.singular" language="en">sg</localized-string><localized-string key="grammar_abbrevs.dual" language="en">dual</localized-string><localized-string key="grammar_abbrevs.pl" language="en">pl</localized-string><localized-string key="grammar_abbrevs.isPreposition" language="en">prep</localized-string><localized-string key="grammar_abbrevs.isParticiple" language="en">part</localized-string><localized-string key="grammar_abbrevs.isAdjective" language="en">adj</localized-string><localized-string key="grammar_abbrevs.isAdverb" language="en">adv</localized-string><localized-string key="grammar_abbrevs.isNoun" language="en">noun</localized-string><localized-string key="grammar_abbrevs.isVerb" language="en">verb</localized-string><localized-string key="relatedterms.deprecates" language="en">deprecates</localized-string><localized-string key="relatedterms.supersedes" language="en">supersedes</localized-string><localized-string key="relatedterms.narrower" language="en">narrower</localized-string><localized-string key="relatedterms.broader" language="en">broader</localized-string><localized-string key="relatedterms.equivalent" language="en">equivalent</localized-string><localized-string key="relatedterms.compare" language="en">compare</localized-string><localized-string key="relatedterms.contrast" language="en">contrast</localized-string><localized-string key="relatedterms.see" language="en">see</localized-string><localized-string key="Clause.sg" language="en">Clause</localized-string><localized-string key="Clause.pl" language="en">Clauses</localized-string><localized-string key="Annex.sg" language="en">Annex</localized-string><localized-string key="Annex.pl" language="en">Annexes</localized-string><localized-string key="Appendix.sg" language="en">Appendix</localized-string><localized-string key="Appendix.pl" language="en">Appendixes</localized-string><localized-string key="Note.sg" language="en">Note</localized-string><localized-string key="Note.pl" language="en">Notes</localized-string><localized-string key="Note_%_to_entry.sg" language="en">Note % to entry</localized-string><localized-string key="Note_%_to_entry.pl" language="en">Notes % to entry</localized-string><localized-string key="List.sg" language="en">List</localized-string><localized-string key="List.pl" language="en">Lists</localized-string><localized-string key="Figure.sg" language="en">Figure</localized-string><localized-string key="Figure.pl" language="en">Figures</localized-string><localized-string key="Formula.sg" language="en">Formula</localized-string><localized-string key="Formula.pl" language="en">Formulas</localized-string><localized-string key="Table.sg" language="en">Table</localized-string><localized-string key="Table.pl" language="en">Tables</localized-string><localized-string key="Requirement.sg" language="en">Requirement</localized-string><localized-string key="Requirement.pl" language="en">Requirements</localized-string><localized-string key="Recommendation.sg" language="en">Recommendation</localized-string><localized-string key="Recommendation.pl" language="en">Recommendations</localized-string><localized-string key="Permission.sg" language="en">Permission</localized-string><localized-string key="Permission.pl" language="en">Permissions</localized-string><localized-string key="Example.sg" language="en">Example</localized-string><localized-string key="Example.pl" language="en">Examples</localized-string><localized-string key="Part.sg" language="en">Part</localized-string><localized-string key="Part.pl" language="en">Parts</localized-string><localized-string key="Section.sg" language="en">Section</localized-string><localized-string key="Section.pl" language="en">Sections</localized-string><localized-string key="Paragraph.sg" language="en">Paragraph</localized-string><localized-string key="Paragraph.pl" language="en">Paragraphs</localized-string><localized-string key="Chapter.sg" language="en">Chapter</localized-string><localized-string key="Chapter.pl" language="en">Chapters</localized-string><localized-string key="Page.sg" language="en">Page</localized-string><localized-string key="Page.pl" language="en">Pages</localized-string><localized-string key="language" language="en">en</localized-string><localized-string key="script" language="en">Latn</localized-string></localized-strings>
13
+ <sections> </sections>
14
+ </standard-document>
@@ -6,6 +6,42 @@ RSpec.describe Metanorma::Standoc do
6
6
  expect(Metanorma::Standoc::VERSION).not_to be nil
7
7
  end
8
8
 
9
+ it "processes named entities" do
10
+ FileUtils.rm_f "test.doc"
11
+ input = <<~INPUT
12
+ = Document title
13
+ Author
14
+ :docfile: test.adoc
15
+ :novalid:
16
+ :no-pdf:
17
+
18
+ Text &times; text
19
+ INPUT
20
+ output = <<~OUTPUT
21
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
22
+ <bibdata type='standard'>
23
+ <title language='en' format='text/plain'>Document title</title>
24
+ <language>en</language>
25
+ <script>Latn</script>
26
+ <status>
27
+ <stage>published</stage>
28
+ </status>
29
+ <copyright>
30
+ <from>#{Time.now.year}</from>
31
+ </copyright>
32
+ <ext>
33
+ <doctype>standard</doctype>
34
+ </ext>
35
+ </bibdata>
36
+ <sections>
37
+ <p id='_'>Text × text</p>
38
+ </sections>
39
+ </standard-document>
40
+ OUTPUT
41
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
42
+ .to be_equivalent_to xmlpp(output)
43
+ end
44
+
9
45
  it "assigns default scripts to major languages" do
10
46
  FileUtils.rm_f "test.doc"
11
47
  input = <<~INPUT
@@ -29,7 +65,7 @@ RSpec.describe Metanorma::Standoc do
29
65
  <from>#{Time.now.year}</from>
30
66
  </copyright>
31
67
  <ext>
32
- <doctype>article</doctype>
68
+ <doctype>standard</doctype>
33
69
  </ext>
34
70
  </bibdata>
35
71
  <sections> </sections>
@@ -125,7 +161,7 @@ RSpec.describe Metanorma::Standoc do
125
161
  </owner>
126
162
  </copyright>
127
163
  <ext>
128
- <doctype>article</doctype>
164
+ <doctype>standard</doctype>
129
165
  </ext>
130
166
  </bibdata>
131
167
  <sections> </sections>
@@ -468,7 +504,7 @@ RSpec.describe Metanorma::Standoc do
468
504
  <keyword>b</keyword>
469
505
  <keyword>c</keyword>
470
506
  <ext>
471
- <doctype>article</doctype>
507
+ <doctype>standard</doctype>
472
508
  <editorialgroup>
473
509
  <technical-committee number="1" type="A">TC</technical-committee>
474
510
  <technical-committee number="11" type="A1">TC1</technical-committee>
@@ -789,7 +825,7 @@ RSpec.describe Metanorma::Standoc do
789
825
  <from>#{Time.now.year}</from>
790
826
  </copyright>
791
827
  <ext>
792
- <doctype>article</doctype>
828
+ <doctype>standard</doctype>
793
829
  </ext>
794
830
  </bibdata>
795
831
  <sections> </sections>
@@ -924,7 +960,7 @@ RSpec.describe Metanorma::Standoc do
924
960
  </bibitem>
925
961
  </relation>
926
962
  <ext>
927
- <doctype>article</doctype>
963
+ <doctype>standard</doctype>
928
964
  </ext>
929
965
  </bibdata>
930
966
  <sections> </sections>
@@ -304,7 +304,7 @@ RSpec.describe Metanorma::Standoc do
304
304
  <from>#{Date.today.year}</from>
305
305
  </copyright>
306
306
  <ext>
307
- <doctype>article</doctype>
307
+ <doctype>standard</doctype>
308
308
  </ext>
309
309
  </bibdata>
310
310
  <sections><p id="foreword">Foreword</p>
@@ -412,6 +412,8 @@ RSpec.describe Metanorma::Standoc do
412
412
 
413
413
  NOTE: This is a note
414
414
 
415
+ WARNING: This is not a note
416
+
415
417
  [NOTE,keep-separate=true,tag=X,multilingual-rendering=common]
416
418
  ====
417
419
  XYZ
@@ -428,6 +430,9 @@ RSpec.describe Metanorma::Standoc do
428
430
  <termnote id="_">
429
431
  <p id="_">This is a note</p>
430
432
  </termnote>
433
+ <admonition id='_' type='warning'>
434
+ <p id='_'>This is not a note</p>
435
+ </admonition>
431
436
  <termnote id='_' tag='X' multilingual-rendering='common'>
432
437
  <p id='_'>XYZ</p>
433
438
  </termnote>
@@ -440,6 +445,32 @@ RSpec.describe Metanorma::Standoc do
440
445
  .to be_equivalent_to xmlpp(output)
441
446
  end
442
447
 
448
+ it "processes term notes outside of terms sections" do
449
+ input = <<~INPUT
450
+ #{ASCIIDOC_BLANK_HDR}
451
+ == Clause
452
+
453
+ [NOTE%termnote]
454
+ ====
455
+ XYZ
456
+ ====
457
+ INPUT
458
+ output = <<~OUTPUT
459
+ #{BLANK_HDR}
460
+ <sections>
461
+ <clause id='_' inline-header='false' obligation='normative'>
462
+ <title>Clause</title>
463
+ <termnote id='_'>
464
+ <p id='_'>XYZ</p>
465
+ </termnote>
466
+ </clause>
467
+ </sections>
468
+ </standard-document>
469
+ OUTPUT
470
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
471
+ .to be_equivalent_to xmlpp(output)
472
+ end
473
+
443
474
  it "processes term notes as plain notes in nonterm clauses" do
444
475
  input = <<~INPUT
445
476
  #{ASCIIDOC_BLANK_HDR}
@@ -722,6 +753,32 @@ RSpec.describe Metanorma::Standoc do
722
753
  .to be_equivalent_to xmlpp(output)
723
754
  end
724
755
 
756
+ it "processes term examples outside of terms sections" do
757
+ input = <<~INPUT
758
+ #{ASCIIDOC_BLANK_HDR}
759
+ == Clause
760
+
761
+ [%termexample]
762
+ ====
763
+ XYZ
764
+ ====
765
+ INPUT
766
+ output = <<~OUTPUT
767
+ #{BLANK_HDR}
768
+ <sections>
769
+ <clause id='_' inline-header='false' obligation='normative'>
770
+ <title>Clause</title>
771
+ <termexample id='_'>
772
+ <p id='_'>XYZ</p>
773
+ </termexample>
774
+ </clause>
775
+ </sections>
776
+ </standard-document>
777
+ OUTPUT
778
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
779
+ .to be_equivalent_to xmlpp(output)
780
+ end
781
+
725
782
  it "processes term examples as plain examples in nonterm clauses" do
726
783
  input = <<~INPUT
727
784
  #{ASCIIDOC_BLANK_HDR}
@@ -467,7 +467,7 @@ RSpec.describe Metanorma::Standoc do
467
467
  <from>#{Time.now.year}</from>
468
468
  </copyright>
469
469
  <ext>
470
- <doctype>article</doctype>
470
+ <doctype>standard</doctype>
471
471
  </ext>
472
472
  </bibdata>
473
473
  <preface>
@@ -762,7 +762,7 @@ RSpec.describe Metanorma::Standoc do
762
762
  <from>#{Time.now.year}</from>
763
763
  </copyright>
764
764
  <ext>
765
- <doctype>article</doctype>
765
+ <doctype>standard</doctype>
766
766
  </ext>
767
767
  </bibdata>
768
768
  <preface>
@@ -996,7 +996,7 @@ RSpec.describe Metanorma::Standoc do
996
996
  <from>#{Time.now.year}</from>
997
997
  </copyright>
998
998
  <ext>
999
- <doctype>article</doctype>
999
+ <doctype>standard</doctype>
1000
1000
  </ext>
1001
1001
  </bibdata>
1002
1002
  <preface>
@@ -1233,7 +1233,7 @@ RSpec.describe Metanorma::Standoc do
1233
1233
  <from>#{Time.now.year}</from>
1234
1234
  </copyright>
1235
1235
  <ext>
1236
- <doctype>article</doctype>
1236
+ <doctype>standard</doctype>
1237
1237
  </ext>
1238
1238
  </bibdata>
1239
1239
  <preface>
@@ -1467,7 +1467,7 @@ RSpec.describe Metanorma::Standoc do
1467
1467
  <from>#{Time.now.year}</from>
1468
1468
  </copyright>
1469
1469
  <ext>
1470
- <doctype>article</doctype>
1470
+ <doctype>standard</doctype>
1471
1471
  </ext>
1472
1472
  </bibdata>
1473
1473
  <preface>
@@ -1713,7 +1713,7 @@ RSpec.describe Metanorma::Standoc do
1713
1713
  <li>
1714
1714
  <p id='_'>
1715
1715
  <xref target='cl2'>
1716
- Clause
1716
+ Clause#{' '}
1717
1717
  <em>A</em>
1718
1718
  <stem type='MathML'>
1719
1719
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -1726,7 +1726,7 @@ RSpec.describe Metanorma::Standoc do
1726
1726
  <li>
1727
1727
  <p id='_'>
1728
1728
  <xref target='a1'>
1729
- Clause
1729
+ Clause#{' '}
1730
1730
  <em>A</em>
1731
1731
  <stem type='MathML'>
1732
1732
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -1766,7 +1766,7 @@ RSpec.describe Metanorma::Standoc do
1766
1766
  <title>Clause2</title>
1767
1767
  <variant-title type='sub'>&#8220;A&#8221; &#8216;B&#8217;</variant-title>
1768
1768
  <variant-title type='toc'>
1769
- Clause
1769
+ Clause#{' '}
1770
1770
  <em>A</em>
1771
1771
  <stem type='MathML'>
1772
1772
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -1780,7 +1780,7 @@ RSpec.describe Metanorma::Standoc do
1780
1780
  <annex id='a1' inline-header='false' obligation='normative'>
1781
1781
  <title>Clause</title>
1782
1782
  <variant-title type='toc'>
1783
- Clause
1783
+ Clause#{' '}
1784
1784
  <em>A</em>
1785
1785
  <stem type='MathML'>
1786
1786
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -1795,4 +1795,55 @@ RSpec.describe Metanorma::Standoc do
1795
1795
  expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
1796
1796
  .to be_equivalent_to xmlpp(output)
1797
1797
  end
1798
+
1799
+ it "processes bibliography annex" do
1800
+ input = <<~INPUT
1801
+ #{ASCIIDOC_BLANK_HDR}
1802
+
1803
+ [appendix]
1804
+ == Bibliography
1805
+
1806
+ [bibliography]
1807
+ === Bibliography
1808
+ INPUT
1809
+ output = <<~OUTPUT
1810
+ <annex id='_' obligation='' language='' script=''>
1811
+ <title>Bibliography</title>
1812
+ <references id='_' normative='false' obligation='informative'>
1813
+ <title>Bibliography</title>
1814
+ </references>
1815
+ </annex>
1816
+ OUTPUT
1817
+ ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
1818
+ expect(xmlpp(strip_guid(ret.at("//xmlns:annex").to_xml)))
1819
+ .to be_equivalent_to(output)
1820
+ end
1821
+
1822
+ it "processes terms annex" do
1823
+ input = <<~INPUT
1824
+ #{ASCIIDOC_BLANK_HDR}
1825
+
1826
+ [appendix]
1827
+ == Terms and definitions
1828
+
1829
+ === Terms and definitions
1830
+ INPUT
1831
+ output = <<~OUTPUT
1832
+ <annex id='_' obligation='' language='' script=''>
1833
+ <terms id='_' obligation='normative'>
1834
+ <title>Terms and definitions</title>
1835
+ <term id='term-Terms-and-definitions'>
1836
+ <preferred>
1837
+ <expression>
1838
+ <name>Terms and definitions</name>
1839
+ </expression>
1840
+ </preferred>
1841
+ </term>
1842
+ </terms>
1843
+ </annex>
1844
+ OUTPUT
1845
+ ret = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
1846
+ expect(xmlpp(strip_guid(ret.at("//xmlns:annex").to_xml)))
1847
+ .to be_equivalent_to(output)
1848
+ end
1798
1849
  end