metanorma-standoc 1.11.3 → 1.11.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7756f8b45a6897bf3a40e48df348a746bc75b30820597fa8ceadedcbbceb89d9
4
- data.tar.gz: e62b62dd699df95d46bd13c18656bf3504c3a34936ff0a094d224d12a9f44987
3
+ metadata.gz: 3cd9e01037065cfbc5d497224c5d6ed6ac5088cd4b4df6f404e08a7c552abcf9
4
+ data.tar.gz: 7eefde1d2046eedbce2c46c8841059210480a43cdea3656bbfd7cfbb068df1b1
5
5
  SHA512:
6
- metadata.gz: 9776d2bfd161b5500e5ac9e8ea47a9597befe1642880a18fdc86839ceee0688e879d37de0bd9000420294f6a0094f455c840643e091a11da0b65489434a44bf9
7
- data.tar.gz: 4f4d5f119ce92541ee1a89320fdc094352f3ca2ac885f1d52438279e4f70b995d0f87b4f7d034bafc63f05e2192b9ae8b7f4063dd1972525d773ec2f66e27dd1
6
+ metadata.gz: 3fcf00d490fa157fdae4029bd261b1d2b3caf09b2d9a7d8e25c67cc0f4e7a474b6baadfedd1f8b9c90d63a8cad59184bafc237500f46cca83364ffd61dc60914
7
+ data.tar.gz: afb262667567181815daf62ba580d124874d1bba843ff6cda2c39a861acf6ec246c04766d8e5822ae3dd77326e22d687cbb255a0562644f1fb07f97f39c67416
@@ -2,6 +2,17 @@ module Asciidoctor
2
2
  module Standoc
3
3
  module Cleanup
4
4
  def termdef_stem_cleanup(xmldoc)
5
+ termdef_stem2admitted(xmldoc)
6
+ xmldoc.xpath("//term//expression/name[stem]").each do |n|
7
+ test = n.dup
8
+ test.at("./stem").remove
9
+ next unless test.text.strip.empty?
10
+
11
+ n.parent.name = "letter-symbol"
12
+ end
13
+ end
14
+
15
+ def termdef_stem2admitted(xmldoc)
5
16
  xmldoc.xpath("//term/p/stem").each do |a|
6
17
  if initial_formula(a.parent)
7
18
  parent = a.parent
@@ -9,12 +20,8 @@ module Asciidoctor
9
20
  end
10
21
  end
11
22
  xmldoc.xpath("//term/formula").each do |a|
12
- if initial_formula(a)
23
+ initial_formula(a) and
13
24
  a.replace("<admitted>#{term_expr(a.children.to_xml)}</admitted>")
14
- end
15
- end
16
- xmldoc.xpath("//term//expression/name[stem]").each do |n|
17
- n.parent.name = "letter-symbol"
18
25
  end
19
26
  end
20
27
 
@@ -38,7 +45,6 @@ module Asciidoctor
38
45
  xmldoc.xpath("//term[dl[@metadata = 'true']]").each do |t|
39
46
  t.xpath("./dl[@metadata = 'true']").each do |dl|
40
47
  prev = related2pref(dl_to_designation(dl)) or next
41
- #require "debug"; binding.b if prev.parent.name == "related"
42
48
  term_dl_to_designation_metadata(prev, dl)
43
49
  term_dl_to_term_metadata(prev, dl)
44
50
  term_dl_to_expression_metadata(prev, dl)
@@ -120,15 +120,19 @@ module Asciidoctor
120
120
  end
121
121
 
122
122
  def metadata_getrelation(node, xml, type, desc = nil)
123
- docs = node.attr(desc || type) || return
123
+ docs = node.attr(desc || type) or return
124
124
  HTMLEntities.new.decode(docs).split(/;\s*/).each do |d|
125
- id = d.split(/,\s*/)
126
- xml.relation **{ type: relation_normalise(type) } do |r|
127
- desc.nil? or r.description relation_normalise(desc)
128
- fetch_ref(r, d, nil, **{}) or r.bibitem do |b|
129
- b.title id[1] || "--"
130
- b.docidentifier id[0]
131
- end
125
+ metadata_getrelation1(d, xml, type, desc)
126
+ end
127
+ end
128
+
129
+ def metadata_getrelation1(doc, xml, type, desc)
130
+ id = doc.split(/,\s*/)
131
+ xml.relation **{ type: relation_normalise(type) } do |r|
132
+ desc.nil? or r.description desc.gsub(/-/, " ")
133
+ fetch_ref(r, doc, nil, **{}) or r.bibitem do |b|
134
+ b.title id[1] || "--"
135
+ b.docidentifier id[0]
132
136
  end
133
137
  end
134
138
  end
@@ -1973,7 +1973,11 @@
1973
1973
  </optional>
1974
1974
  <element name="name">
1975
1975
  <zeroOrMore>
1976
- <ref name="PureTextElement"/>
1976
+ <choice>
1977
+ <ref name="PureTextElement"/>
1978
+ <ref name="stem"/>
1979
+ <ref name="index"/>
1980
+ </choice>
1977
1981
  </zeroOrMore>
1978
1982
  </element>
1979
1983
  <optional>
@@ -1987,7 +1991,7 @@
1987
1991
  </element>
1988
1992
  </optional>
1989
1993
  <optional>
1990
- <element name="grammar-info">
1994
+ <element name="grammar">
1991
1995
  <ref name="Grammar"/>
1992
1996
  </element>
1993
1997
  </optional>
@@ -73,16 +73,14 @@ module Asciidoctor
73
73
  end
74
74
 
75
75
  def pdf_extract_attributes(node)
76
- attrs =
77
- %w(pdf-encrypt pdf-encryption-length pdf-user-password
78
- pdf-owner-password pdf-allow-copy-content pdf-allow-edit-content
79
- pdf-allow-assemble-document pdf-allow-edit-annotations
80
- pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
81
- pdf-allow-access-content pdf-encrypt-metadata)
82
- .each_with_object({}) do |x, m|
83
- m[x.gsub(/-/, "").to_i] = node.attr(x)
84
- end
85
- html_extract_attributes(node).merge(attrs)
76
+ %w(pdf-encrypt pdf-encryption-length pdf-user-password
77
+ pdf-owner-password pdf-allow-copy-content pdf-allow-edit-content
78
+ pdf-allow-assemble-document pdf-allow-edit-annotations
79
+ pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
80
+ pdf-allow-access-content pdf-encrypt-metadata)
81
+ .each_with_object({}) do |x, m|
82
+ m[x.gsub(/-/, "").to_i] = node.attr(x)
83
+ end
86
84
  end
87
85
 
88
86
  def doc_converter(node)
@@ -190,6 +190,19 @@ module Asciidoctor
190
190
  xml_section << content
191
191
  end
192
192
  end
193
+
194
+ def floating_title_attrs(node)
195
+ attr_code(id_attr(node).merge(align: node.attr("align"),
196
+ type: "floating-title"))
197
+ end
198
+
199
+ def floating_title(node)
200
+ noko do |xml|
201
+ xml.p **floating_title_attrs(node) do |xml_t|
202
+ xml_t << node.title
203
+ end
204
+ end.join("\n")
205
+ end
193
206
  end
194
207
  end
195
208
  end
@@ -105,8 +105,14 @@ module Asciidoctor
105
105
  else
106
106
  attrs = term_source_attrs(node, seen_xref)
107
107
  attrs.delete(:text)
108
- xml_t.origin seen_xref.children[0].content, **attr_code(attrs)
108
+ xml_t.origin **attr_code(attrs) do |o|
109
+ o << seen_xref.children[0].children.to_xml
110
+ end
109
111
  end
112
+ add_term_source_mod(xml_t, match)
113
+ end
114
+
115
+ def add_term_source_mod(xml_t, match)
110
116
  match[:text] && xml_t.modification do |mod|
111
117
  mod.p { |p| p << match[:text].sub(/^\s+/, "") }
112
118
  end
@@ -76,6 +76,12 @@ code *, pre *, tt *, kbd *, samp * {
76
76
  font-family: {{monospacefont}} !important;
77
77
  font-variant-ligatures: none; }
78
78
 
79
+ p code, dt code, li code, label code, legend code, caption code, th code, td code,
80
+ p tt, dt tt, li tt, label tt, legend tt, caption tt, th tt, td tt,
81
+ p kbd, dt kbd, li kbd, label kbd, legend kbd, caption kbd, th kbd, td kbd,
82
+ p samp, dt samp, li samp, label samp, legend samp, caption samp, th samp, td samp {
83
+ font-size: {{monospacefontsize}}; }
84
+
79
85
  article, aside, details, figcaption, figure,
80
86
  footer, header, hgroup, menu, nav, section {
81
87
  display: block; }
@@ -87,6 +93,9 @@ table {
87
93
  h1, h2, h3, h4, h5, h6 {
88
94
  font-family: {{headerfont}}; }
89
95
 
96
+ .h1, .h2, .h3, .h4, .h5, .h6 {
97
+ font-family: {{headerfont}}; }
98
+
90
99
  blockquote, q {
91
100
  quotes: none; }
92
101
  blockquote:before, blockquote:after, q:before, q:after {
@@ -467,27 +476,27 @@ p.document-stage {
467
476
  /*
468
477
  3.1 Titles
469
478
  */
470
- h1, h2, h3, h4, h5, h6 {
479
+ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
471
480
  font-family: {{headerfont}};
472
481
  color: #C70039;
473
482
  font-weight: 300;
474
483
  margin-top: 1.6em;
475
484
  margin-bottom: 0.3em; }
476
485
 
477
- h1 {
486
+ h1, .h1 {
478
487
  font-size: 1.6em;
479
488
  text-transform: uppercase;
480
489
  margin-top: 2em; }
481
490
 
482
- h1#content {
491
+ h1#content, #content.h1 {
483
492
  margin-top: 2em; }
484
493
 
485
- h2 {
494
+ h2, .h2 {
486
495
  margin-top: 1.3em;
487
496
  font-size: 1.3em;
488
497
  font-weight: 400; }
489
498
 
490
- h3 {
499
+ h3, .h3 {
491
500
  margin-top: 1.1em;
492
501
  font-size: 1.1em;
493
502
  font-weight: 100; }
@@ -791,7 +800,7 @@ p {
791
800
  margin-top: 1em;
792
801
  margin-bottom: 1em; }
793
802
 
794
- h2 p {
803
+ h2 p, .h2 p {
795
804
  display: inline; }
796
805
 
797
806
  /*
@@ -942,7 +951,7 @@ To top button
942
951
  @media print {
943
952
  .document-info, nav, .copyright {
944
953
  page-break-before: always; }
945
- h1, h2, h3, h4 {
954
+ h1, h2, h3, h4, .h1, .h2, .h3, .h4 {
946
955
  page-break-after: avoid;
947
956
  margin-top: 1.2em; }
948
957
  .note, .figure, pre, .pseudocode, table {
@@ -965,12 +974,12 @@ To top button
965
974
  h1.content {
966
975
  margin-top: 2em;
967
976
  line-height: 2.5em; }
968
- h1 {
977
+ h1, .h1 {
969
978
  font-size: 1.5em;
970
979
  line-height: 1.5; }
971
- h2 {
980
+ h2, .h2 {
972
981
  font-size: 1.2em; }
973
- h3 {
982
+ h3, .h3 {
974
983
  font-size: 1em; }
975
984
  .Note {
976
985
  background-color: #fff495;
@@ -155,7 +155,7 @@ p.document-stage {
155
155
  3.1 Titles
156
156
  */
157
157
 
158
- h1,h2,h3,h4,h5,h6 {
158
+ h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6 {
159
159
  font-family: $headerfont;
160
160
  color: #C70039;
161
161
  font-weight: 300;
@@ -163,23 +163,23 @@ p.document-stage {
163
163
  margin-bottom: 0.3em;
164
164
  }
165
165
 
166
- h1 {
166
+ h1,.h1 {
167
167
  font-size: 1.6em;
168
168
  text-transform: uppercase;
169
169
  margin-top: 2em;
170
170
  }
171
171
 
172
- h1#content {
172
+ h1#content,.h1#content {
173
173
  margin-top: 2em;
174
174
  }
175
175
 
176
- h2 {
176
+ h2,.h2 {
177
177
  margin-top: 1.3em;
178
178
  font-size: 1.3em;
179
179
  font-weight: 400;
180
180
  }
181
181
 
182
- h3 {
182
+ h3,.h3 {
183
183
  margin-top: 1.1em;
184
184
  font-size: 1.1em;
185
185
  font-weight: 100;
@@ -471,7 +471,7 @@ p {
471
471
  margin-bottom: 1em;
472
472
  }
473
473
 
474
- h2 p {
474
+ h2 p, .h2 p {
475
475
  display: inline;
476
476
  }
477
477
 
@@ -643,7 +643,7 @@ To top button
643
643
  page-break-before: always;
644
644
  }
645
645
 
646
- h1, h2, h3, h4 {
646
+ h1, h2, h3, h4, .h1, .h2, .h3, .h4 {
647
647
  page-break-after: avoid;
648
648
  margin-top: 1.2em;
649
649
  }
@@ -685,16 +685,16 @@ To top button
685
685
  line-height: 2.5em;
686
686
  }
687
687
 
688
- h1 {
688
+ h1, .h1 {
689
689
  font-size: 1.5em;
690
690
  line-height: 1.5;
691
691
  }
692
692
 
693
- h2 {
693
+ h2, .h2 {
694
694
  font-size: 1.2em
695
695
  }
696
696
 
697
- h3 {
697
+ h3, .h3 {
698
698
  font-size: 1em;
699
699
  }
700
700
 
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "1.11.3".freeze
22
+ VERSION = "1.11.4".freeze
23
23
  end
24
24
  end
@@ -849,6 +849,47 @@ RSpec.describe Asciidoctor::Standoc do
849
849
  .to be_equivalent_to xmlpp(output)
850
850
  end
851
851
 
852
+ it "processes document relations by description" do
853
+ mock_relaton_relation_descriptions
854
+ input = <<~INPUT
855
+ = Document title
856
+ Author
857
+ :docfile: test.adoc
858
+ :nodoc:
859
+ :novalid:
860
+ :normatively-cited-in: ABC
861
+
862
+ INPUT
863
+ output = <<~OUTPUT
864
+ <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
865
+ <bibdata type='standard'>
866
+ <title language='en' format='text/plain'>Document title</title>
867
+ <language>en</language>
868
+ <script>Latn</script>
869
+ <status>
870
+ <stage>published</stage>
871
+ </status>
872
+ <copyright>
873
+ <from>2021</from>
874
+ </copyright>
875
+ <relation type='isCitedIn'>
876
+ <description>normatively cited in</description>
877
+ <bibitem>
878
+ <title>--</title>
879
+ <docidentifier>ABC</docidentifier>
880
+ </bibitem>
881
+ </relation>
882
+ <ext>
883
+ <doctype>article</doctype>
884
+ </ext>
885
+ </bibdata>
886
+ <sections> </sections>
887
+ </standard-document>
888
+ OUTPUT
889
+ expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
890
+ .to be_equivalent_to xmlpp(output)
891
+ end
892
+
852
893
  it "reads scripts into blank HTML document" do
853
894
  FileUtils.rm_f "test.html"
854
895
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
@@ -986,4 +1027,11 @@ QU1FOiB0ZXN0Cgo=
986
1027
  "International Standards Organization",
987
1028
  )
988
1029
  end
1030
+
1031
+ def mock_relaton_relation_descriptions
1032
+ allow_any_instance_of(::Asciidoctor::Standoc::Front)
1033
+ .to receive(:relaton_relation_descriptions).and_return(
1034
+ "normatively-cited-in" => "isCitedIn",
1035
+ )
1036
+ end
989
1037
  end
@@ -705,6 +705,114 @@ RSpec.describe Asciidoctor::Standoc do
705
705
  .to be_equivalent_to xmlpp(output)
706
706
  end
707
707
 
708
+ it "differentiates stem-only and mixed terms" do
709
+ input = <<~INPUT
710
+ #{ASCIIDOC_BLANK_HDR}
711
+ == Terms and Definitions
712
+
713
+ === stem:[t_90]
714
+
715
+ Time
716
+
717
+ === stem:[t_90]-sensitivity
718
+
719
+ Sensitivity
720
+
721
+ === sensitivity to stem:[t_90]
722
+
723
+ Sensitivity #2
724
+ INPUT
725
+ output = <<~OUTPUT
726
+ #{BLANK_HDR}
727
+ <sections>
728
+ <terms id='_' obligation='normative'>
729
+ <title>Terms and definitions</title>
730
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
731
+ <term id='term-_-t90-'>
732
+ <preferred>
733
+ <letter-symbol>
734
+ <name>
735
+ <stem type='MathML'>
736
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
737
+ <msub>
738
+ <mrow>
739
+ <mi>t</mi>
740
+ </mrow>
741
+ <mrow>
742
+ <mn>90</mn>
743
+ </mrow>
744
+ </msub>
745
+ </math>
746
+ </stem>
747
+ </name>
748
+ </letter-symbol>
749
+ </preferred>
750
+ <definition>
751
+ <verbal-definition>
752
+ <p id='_'>Time</p>
753
+ </verbal-definition>
754
+ </definition>
755
+ </term>
756
+ <term id='term-t90-sensitivity'>
757
+ <preferred>
758
+ <expression>
759
+ <name>
760
+ <stem type='MathML'>
761
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
762
+ <msub>
763
+ <mrow>
764
+ <mi>t</mi>
765
+ </mrow>
766
+ <mrow>
767
+ <mn>90</mn>
768
+ </mrow>
769
+ </msub>
770
+ </math>
771
+ </stem>
772
+ -sensitivity
773
+ </name>
774
+ </expression>
775
+ </preferred>
776
+ <definition>
777
+ <verbal-definition>
778
+ <p id='_'>Sensitivity</p>
779
+ </verbal-definition>
780
+ </definition>
781
+ </term>
782
+ <term id='term-sensitivity-to-t90'>
783
+ <preferred>
784
+ <expression>
785
+ <name>
786
+ sensitivity to
787
+ <stem type='MathML'>
788
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
789
+ <msub>
790
+ <mrow>
791
+ <mi>t</mi>
792
+ </mrow>
793
+ <mrow>
794
+ <mn>90</mn>
795
+ </mrow>
796
+ </msub>
797
+ </math>
798
+ </stem>
799
+ </name>
800
+ </expression>
801
+ </preferred>
802
+ <definition>
803
+ <verbal-definition>
804
+ <p id='_'>Sensitivity #2</p>
805
+ </verbal-definition>
806
+ </definition>
807
+ </term>
808
+ </terms>
809
+ </sections>
810
+ </standard-document>
811
+ OUTPUT
812
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
813
+ .to be_equivalent_to xmlpp(output)
814
+ end
815
+
708
816
  it "moves term domains out of the term definition paragraph" do
709
817
  input = <<~INPUT
710
818
  #{ASCIIDOC_BLANK_HDR}
@@ -1224,7 +1332,7 @@ RSpec.describe Asciidoctor::Standoc do
1224
1332
  x^2^:: Definition
1225
1333
  INPUT
1226
1334
  output = <<~OUTPUT
1227
- <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='1.11.2'>
1335
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
1228
1336
  <bibdata type='standard'>
1229
1337
  <title language='en' format='text/plain'>Document title</title>
1230
1338
  <language>en</language>