metanorma-standoc 2.1.5 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +13 -0
  3. data/lib/metanorma/standoc/blocks.rb +26 -17
  4. data/lib/metanorma/standoc/cleanup.rb +1 -1
  5. data/lib/metanorma/standoc/cleanup_biblio.rb +210 -0
  6. data/lib/metanorma/standoc/cleanup_block.rb +6 -4
  7. data/lib/metanorma/standoc/cleanup_maths.rb +2 -15
  8. data/lib/metanorma/standoc/cleanup_ref.rb +22 -13
  9. data/lib/metanorma/standoc/cleanup_reqt.rb +3 -103
  10. data/lib/metanorma/standoc/cleanup_symbols.rb +1 -1
  11. data/lib/metanorma/standoc/cleanup_text.rb +10 -8
  12. data/lib/metanorma/standoc/cleanup_xref.rb +1 -2
  13. data/lib/metanorma/standoc/converter.rb +2 -0
  14. data/lib/metanorma/standoc/front.rb +1 -1
  15. data/lib/metanorma/standoc/front_contributor.rb +0 -10
  16. data/lib/metanorma/standoc/inline.rb +8 -4
  17. data/lib/metanorma/standoc/isodoc.rng +6 -1
  18. data/lib/metanorma/standoc/macros.rb +1 -180
  19. data/lib/metanorma/standoc/macros_inline.rb +194 -0
  20. data/lib/metanorma/standoc/ref_sect.rb +2 -2
  21. data/lib/metanorma/standoc/ref_utility.rb +1 -1
  22. data/lib/metanorma/standoc/reqt.rb +19 -75
  23. data/lib/metanorma/standoc/reqt.rng +1 -1
  24. data/lib/metanorma/standoc/section.rb +35 -3
  25. data/lib/metanorma/standoc/utils.rb +9 -43
  26. data/lib/metanorma/standoc/validate.rb +1 -69
  27. data/lib/metanorma/standoc/validate_table.rb +91 -0
  28. data/lib/metanorma/standoc/version.rb +1 -1
  29. data/metanorma-standoc.gemspec +4 -5
  30. data/spec/metanorma/{refs_dl_spec.rb → biblio_spec.rb} +90 -7
  31. data/spec/metanorma/blocks_spec.rb +31 -267
  32. data/spec/metanorma/cleanup_blocks_spec.rb +0 -171
  33. data/spec/metanorma/inline_spec.rb +4 -0
  34. data/spec/metanorma/macros_concept_spec.rb +1033 -0
  35. data/spec/metanorma/macros_spec.rb +2 -1030
  36. data/spec/metanorma/refs_spec.rb +0 -2
  37. data/spec/metanorma/reqt_spec.rb +130 -0
  38. data/spec/metanorma/section_spec.rb +5 -0
  39. data/spec/metanorma/validate_spec.rb +46 -6
  40. data/spec/vcr_cassettes/bsi16341.yml +80 -52
  41. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +94 -94
  42. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
  43. data/spec/vcr_cassettes/hide_refs.yml +70 -70
  44. data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
  45. data/spec/vcr_cassettes/isobib_get_123_1.yml +23 -23
  46. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  47. data/spec/vcr_cassettes/isobib_get_123_2.yml +22 -22
  48. data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
  49. data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
  50. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +34 -64
  51. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
  52. data/spec/vcr_cassettes/std-link.yml +12 -12
  53. metadata +15 -11
  54. data/lib/metanorma/standoc/cleanup_ref_dl.rb +0 -113
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.0
47
+ version: 2.2.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.0
54
+ version: 2.2.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: metanorma-plugin-datastruct
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -151,33 +151,33 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: metanorma-utils
154
+ name: mn-requirements
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.2.8
159
+ version: 0.0.1
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.2.8
166
+ version: 0.0.1
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: relaton-cli
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 1.12.0
173
+ version: 1.13.0
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 1.12.0
180
+ version: 1.13.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: relaton-iev
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -477,6 +477,7 @@ files:
477
477
  - lib/metanorma/standoc/blocks_notes.rb
478
478
  - lib/metanorma/standoc/cleanup.rb
479
479
  - lib/metanorma/standoc/cleanup_amend.rb
480
+ - lib/metanorma/standoc/cleanup_biblio.rb
480
481
  - lib/metanorma/standoc/cleanup_block.rb
481
482
  - lib/metanorma/standoc/cleanup_boilerplate.rb
482
483
  - lib/metanorma/standoc/cleanup_footnotes.rb
@@ -484,7 +485,6 @@ files:
484
485
  - lib/metanorma/standoc/cleanup_inline.rb
485
486
  - lib/metanorma/standoc/cleanup_maths.rb
486
487
  - lib/metanorma/standoc/cleanup_ref.rb
487
- - lib/metanorma/standoc/cleanup_ref_dl.rb
488
488
  - lib/metanorma/standoc/cleanup_reqt.rb
489
489
  - lib/metanorma/standoc/cleanup_section.rb
490
490
  - lib/metanorma/standoc/cleanup_section_names.rb
@@ -507,6 +507,7 @@ files:
507
507
  - lib/metanorma/standoc/macros.rb
508
508
  - lib/metanorma/standoc/macros_embed.rb
509
509
  - lib/metanorma/standoc/macros_form.rb
510
+ - lib/metanorma/standoc/macros_inline.rb
510
511
  - lib/metanorma/standoc/macros_note.rb
511
512
  - lib/metanorma/standoc/macros_plantuml.rb
512
513
  - lib/metanorma/standoc/macros_terms.rb
@@ -524,6 +525,7 @@ files:
524
525
  - lib/metanorma/standoc/utils.rb
525
526
  - lib/metanorma/standoc/validate.rb
526
527
  - lib/metanorma/standoc/validate_section.rb
528
+ - lib/metanorma/standoc/validate_table.rb
527
529
  - lib/metanorma/standoc/version.rb
528
530
  - lib/metanorma/standoc/views/datamodel/model_representation.adoc.erb
529
531
  - lib/metanorma/standoc/views/datamodel/plantuml_representation.adoc.erb
@@ -607,6 +609,7 @@ files:
607
609
  - spec/fixtures/test.exp
608
610
  - spec/fixtures/test.xmi
609
611
  - spec/metanorma/base_spec.rb
612
+ - spec/metanorma/biblio_spec.rb
610
613
  - spec/metanorma/blank_spec.rb
611
614
  - spec/metanorma/blocks_spec.rb
612
615
  - spec/metanorma/cleanup_blocks_spec.rb
@@ -618,13 +621,14 @@ files:
618
621
  - spec/metanorma/inline_spec.rb
619
622
  - spec/metanorma/isobib_cache_spec.rb
620
623
  - spec/metanorma/lists_spec.rb
624
+ - spec/metanorma/macros_concept_spec.rb
621
625
  - spec/metanorma/macros_json2text_spec.rb
622
626
  - spec/metanorma/macros_plantuml_spec.rb
623
627
  - spec/metanorma/macros_spec.rb
624
628
  - spec/metanorma/macros_yaml2text_spec.rb
625
629
  - spec/metanorma/processor_spec.rb
626
- - spec/metanorma/refs_dl_spec.rb
627
630
  - spec/metanorma/refs_spec.rb
631
+ - spec/metanorma/reqt_spec.rb
628
632
  - spec/metanorma/section_spec.rb
629
633
  - spec/metanorma/table_spec.rb
630
634
  - spec/metanorma/validate_spec.rb
@@ -1,113 +0,0 @@
1
- require "set"
2
- require "relaton_bib"
3
-
4
- module Metanorma
5
- module Standoc
6
- module Cleanup
7
- def ref_dl_cleanup(xmldoc)
8
- xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
9
- bib = dl_bib_extract(c) or next
10
- validate_ref_dl(bib, c)
11
- bibitemxml = RelatonBib::BibliographicItem.from_hash(bib).to_xml or next
12
- bibitem = Nokogiri::XML(bibitemxml)
13
- bibitem.root["id"] = c["id"] if c["id"] && !/^_/.match(c["id"])
14
- c.replace(bibitem.root)
15
- end
16
- end
17
-
18
- # do not accept implicit id
19
- def validate_ref_dl(bib, clause)
20
- id = bib["id"]
21
- id ||= clause["id"] unless /^_/.match?(clause["id"])
22
- unless id
23
- @log.add("Anchors", clause,
24
- "The following reference is missing an anchor:\n"\
25
- "#{clause.to_xml}")
26
- return
27
- end
28
- @refids << id
29
- validate_ref_dl1(bib, id, clause)
30
- end
31
-
32
- def validate_ref_dl1(bib, id, clause)
33
- bib["title"] or
34
- @log.add("Bibliography", clause, "Reference #{id} is missing a title")
35
- bib["docid"] or
36
- @log.add("Bibliography", clause,
37
- "Reference #{id} is missing a document identifier (docid)")
38
- end
39
-
40
- def extract_from_p(tag, bib, key)
41
- return unless bib[tag]
42
-
43
- "<#{key}>#{bib[tag].at('p').children}</#{key}>"
44
- end
45
-
46
- # if the content is a single paragraph, replace it with its children
47
- # single links replaced with uri
48
- def p_unwrap(para)
49
- elems = para.elements
50
- if elems.size == 1 && elems[0].name == "p"
51
- link_unwrap(elems[0]).children.to_xml.strip
52
- else
53
- para.to_xml.strip
54
- end
55
- end
56
-
57
- def link_unwrap(para)
58
- elems = para.elements
59
- if elems.size == 1 && elems[0].name == "link"
60
- para.at("./link").replace(elems[0]["target"].strip)
61
- end
62
- para
63
- end
64
-
65
- def dd_bib_extract(dtd)
66
- return nil if dtd.children.empty?
67
-
68
- dtd.at("./dl") and return dl_bib_extract(dtd)
69
- elems = dtd.remove.elements
70
- return p_unwrap(dtd) unless elems.size == 1 &&
71
- %w(ol ul).include?(elems[0].name)
72
-
73
- ret = []
74
- elems[0].xpath("./li").each do |li|
75
- ret << p_unwrap(li)
76
- end
77
- ret
78
- end
79
-
80
- def add_to_hash(bib, key, val)
81
- Metanorma::Utils::set_nested_value(bib, key.split("."), val)
82
- end
83
-
84
- # definition list, with at most one level of unordered lists
85
- def dl_bib_extract(clause, nested = false)
86
- dl = clause.at("./dl") or return
87
- bib = {}
88
- key = ""
89
- dl.xpath("./dt | ./dd").each do |dtd|
90
- (dtd.name == "dt" and key = dtd.text.sub(/:+$/, "")) or
91
- add_to_hash(bib, key, dd_bib_extract(dtd))
92
- end
93
- clause.xpath("./clause").each do |c1|
94
- key = c1&.at("./title")&.text&.downcase&.strip
95
- next unless %w(contributor relation series).include? key
96
-
97
- add_to_hash(bib, key, dl_bib_extract(c1, true))
98
- end
99
- dl_bib_extract_title(bib, clause, nested)
100
- end
101
-
102
- def dl_bib_extract_title(bib, clause, nested)
103
- (!nested && clause.at("./title")) or return bib
104
- title = clause.at("./title").remove.children.to_xml
105
- bib["title"] = [bib["title"]] if bib["title"].is_a?(Hash) ||
106
- bib["title"].is_a?(String)
107
- bib["title"] = [] unless bib["title"]
108
- bib["title"] << title if !title.empty?
109
- bib
110
- end
111
- end
112
- end
113
- end