metanorma-standoc 3.4.9 → 3.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a76abb834a587adae31dae92f93936ca82968bc7b77a9d907633b51a0de29319
4
- data.tar.gz: a03fe3c22052427818cc8161c376786c27b3ee570dec4f4fa243713b54ef30a6
3
+ metadata.gz: b5094a6f74d9378c42e68b279963b6ac50f9c94412e259175c5d689111ddf6e6
4
+ data.tar.gz: 193d1ecb96eaba4fe068290844230558579feb43a911ac55f11d0cac086bb073
5
5
  SHA512:
6
- metadata.gz: 17ac7b991acf83f47f01e79c8c0eb71f1531db814c77ec60b5fa69b0828707a25702f83a92492b49a2217f23525287d22fb6e064b3a48a3b3ecbbc8646a964d4
7
- data.tar.gz: df7537f969e7559c90569125da0c3847da7cc723c998f96e1393229607d22271191b909c36262a8ee89a0c63fea20b5a4e005fa925e430c6b2e6b08d6699c1a6
6
+ metadata.gz: 793e4b2daecbde3ff0778cf36373bf9e6fc4ba63705bc7b42b545dc7fa6f52a40f6776325f15d55aaa18ea16e94fafbec88540896ae04f85989d97c67474a021
7
+ data.tar.gz: 90d033cbd1290db48e3a8fd9c33817970c8fb7488c13782b1fbd7ff7519105d4cf5608eeed51e014f9b85645c9d7036dc745a97d6c74a00adf5f92f6ccc173b5
@@ -137,6 +137,10 @@ dl dd {
137
137
  grid-column-start: 2;
138
138
  }
139
139
 
140
+ dl:has(dt .stem) {
141
+ grid-template-columns: fit-content(8em) auto;
142
+ }
143
+
140
144
  b, strong {
141
145
  font-weight: bold;
142
146
  }
@@ -34,6 +34,26 @@ module Metanorma
34
34
  bib.children = new.children.to_xml
35
35
  else bib << new.children.to_xml
36
36
  end
37
+ bibitem_reorder_elems(bib)
38
+ end
39
+
40
+ # canonical element order of BibliographicItem per biblio.rnc
41
+ BIBITEM_ELEM_ORDER =
42
+ %w(fetched formattedref title uri docidentifier docnumber date
43
+ contributor edition version note language locale script abstract
44
+ status copyright relation series medium place price extent size
45
+ accesslocation license classification keyword validity depiction)
46
+ .freeze
47
+
48
+ # the spans-derived fragment is appended after any elements already on
49
+ # the bibitem (e.g. formattedref, docnumber, date), which violates the
50
+ # ordered relaton content model; restore grammar order, stably
51
+ def bibitem_reorder_elems(bib)
52
+ bib.element_children
53
+ .sort_by
54
+ .with_index do |e, i|
55
+ [BIBITEM_ELEM_ORDER.index(e.name) || BIBITEM_ELEM_ORDER.size, i]
56
+ end.each { |e| bib << e }
37
57
  end
38
58
 
39
59
  def merge_bibitem_from_formattedref_span_attrs(bib, new)
@@ -1,10 +1,13 @@
1
1
  module Metanorma
2
2
  module Standoc
3
3
  module Index
4
+ # normalize-space(.) rather than normalize-space(text()): index terms
5
+ # wrapped entirely in formatting (<em>a priori</em>, stem) have no
6
+ # direct text nodes but are not empty
4
7
  EMPTY_INDEX_XPATH =
5
- "//index[not(.//primary[normalize-space(text())]) " \
6
- "or .//secondary[. and not(normalize-space(text()))] " \
7
- "or .//tertiary[. and not(normalize-space(text()))]]".freeze
8
+ "//index[not(.//primary[normalize-space(.)]) " \
9
+ "or .//secondary[. and not(normalize-space(.))] " \
10
+ "or .//tertiary[. and not(normalize-space(.))]]".freeze
8
11
 
9
12
  def index_cleanup(xmldoc)
10
13
  para_index_cleanup(xmldoc)
@@ -35,6 +35,11 @@ module Metanorma
35
35
  when "ol", "ul" then node.at(".//p | .//name") || node.at("./li")
36
36
  when "dl" then node.at(".//p | .//name") || node.at("./dt | ./dd")
37
37
  when "table" then node.at(".//td[text()] | .//th[text()]")
38
+ # terms and their children have no legal place for a loose
39
+ # paragraph, so the bookmark must land inside existing content
40
+ when "term", "definition", "verbal-definition", "preferred",
41
+ "admitted", "deprecates", "related", "termnote", "termexample"
42
+ node.at(".//p | .//name")
38
43
  end or return nil
39
44
  first_non_stem_text(ret)
40
45
  end
@@ -58,7 +58,9 @@ module Metanorma
58
58
  ret += span_to_docid(s, "classification")
59
59
  end
60
60
  spans[:keyword]&.each do |s|
61
- ret += span_to_docid(s, "keyword")
61
+ # keyword content is structured per the grammar: an uncontrolled
62
+ # keyword is a vocab entry, not bare text
63
+ ret += "<keyword><vocab>#{s[:val]}</vocab></keyword>"
62
64
  end
63
65
  spans[:image]&.each do |s|
64
66
  ret += "<depiction>#{s[:val]}</depiction>"
@@ -58,7 +58,7 @@ module Metanorma
58
58
  pronunciation|grammar|term|terms|termnote|termexample|source|
59
59
  origin|termref|modification)>)}x, "\\1\n")
60
60
  .gsub(%r{(<(title|name))}, "\n\\1")
61
- .gsub(%r{(<sourcecode[^<>]*>)\s+(<name[^<>]*>[^<]+</name>)\s+},
61
+ .gsub(%r{(<sourcecode[^<>]*+>)\s++(<name[^<>]*+>(?>.*?</name>))\s++}m,
62
62
  "\\1\\2")
63
63
  end
64
64
 
@@ -54,6 +54,12 @@ module Metanorma
54
54
  preprocessor Metanorma::Standoc::NamedEscapePreprocessor
55
55
  inline_macro Metanorma::Standoc::PreferredTermInlineMacro
56
56
  inline_macro Metanorma::Standoc::DateInlineMacro
57
+ # PassFormat must run before Span (and the other bracketed inline macros
58
+ # below) so that a nested pass/pass-format passthrough is resolved to a
59
+ # bracket-free placeholder before Span delimits its own [...]; otherwise
60
+ # Span stops at the inner passthrough's ] and over-captures. See
61
+ # metanorma-standoc#1221.
62
+ inline_macro Metanorma::Standoc::PassFormatInlineMacro
57
63
  inline_macro Metanorma::Standoc::SpanInlineMacro
58
64
  inline_macro Metanorma::Standoc::AltTermInlineMacro
59
65
  inline_macro Metanorma::Standoc::AdmittedTermInlineMacro
@@ -79,7 +85,6 @@ module Metanorma
79
85
  inline_macro Metanorma::Standoc::FormSelectMacro
80
86
  inline_macro Metanorma::Standoc::FormOptionMacro
81
87
  inline_macro Metanorma::Standoc::ToCInlineMacro
82
- inline_macro Metanorma::Standoc::PassFormatInlineMacro
83
88
  inline_macro Metanorma::Standoc::StdLinkInlineMacro
84
89
  inline_macro Metanorma::Standoc::NumberInlineMacro
85
90
  inline_macro Metanorma::Standoc::TrStyleInlineMacro
@@ -174,7 +174,12 @@ module Metanorma
174
174
  def metadata_keywords(node, xml)
175
175
  node.attr("keywords") or return
176
176
  node.attr("keywords").split(/,\s*/).each do |kw|
177
- add_noko_elem(xml, "keyword", kw)
177
+ kw.empty? and next
178
+ # keyword content is structured per the grammar: an uncontrolled
179
+ # keyword is a vocab entry, not bare text
180
+ xml.keyword do |k|
181
+ add_noko_elem(k, "vocab", kw)
182
+ end
178
183
  end
179
184
  end
180
185
 
@@ -160,12 +160,19 @@ module Metanorma
160
160
  uri
161
161
  end
162
162
 
163
+ # empty-string dimensions (image::x.png["","",""]) must fall back to
164
+ # "auto": ImageSize admits only numbers, percentages, or "auto"
165
+ def image_dim_attr(node, key)
166
+ ret = node.attr(key)
167
+ ret.nil? || ret.empty? ? "auto" : ret
168
+ end
169
+
163
170
  def image_attributes1(node, uri, sourceuri, type, altmedia)
164
171
  /^data:/.match?(sourceuri) and sourceuri = nil
165
172
  attr_code(altmedia_id_attr(node, altmedia)
166
173
  .merge(src: uri, mimetype: type,
167
- height: node.attr("height") || "auto",
168
- width: node.attr("width") || "auto",
174
+ height: image_dim_attr(node, "height"),
175
+ width: image_dim_attr(node, "width"),
169
176
  filename: node.attr("filename") || sourceuri,
170
177
  title: node.attr("titleattr"),
171
178
  media: node.attr("media"), altmedia: altmedia,
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "3.4.9".freeze
22
+ VERSION = "3.4.10".freeze
23
23
  end
24
24
  end
@@ -1527,12 +1527,16 @@ to indicate that the index range covers a range of locations between the current
1527
1527
  <ref name="index-primary">
1528
1528
  <a:documentation>Primary index term to be recorded at the current location</a:documentation>
1529
1529
  </ref>
1530
- <ref name="index-secondary">
1531
- <a:documentation>Secondary index term to be recorded at the current location</a:documentation>
1532
- </ref>
1533
- <ref name="index-tertiary">
1534
- <a:documentation>Tertiary index term to be recorded at the current </a:documentation>
1535
- </ref>
1530
+ <optional>
1531
+ <ref name="index-secondary">
1532
+ <a:documentation>Secondary index term to be recorded at the current location</a:documentation>
1533
+ </ref>
1534
+ </optional>
1535
+ <optional>
1536
+ <ref name="index-tertiary">
1537
+ <a:documentation>Tertiary index term to be recorded at the current </a:documentation>
1538
+ </ref>
1539
+ </optional>
1536
1540
  </element>
1537
1541
  </define>
1538
1542
  <define name="index-xref">
@@ -1547,12 +1551,16 @@ The text in the inline element is the primary index term to be be cross-referenc
1547
1551
  <ref name="index-primary">
1548
1552
  <a:documentation>The primary index term to be cross-referenced</a:documentation>
1549
1553
  </ref>
1550
- <ref name="index-secondary">
1551
- <a:documentation>The secondary index term to be cross-referenced</a:documentation>
1552
- </ref>
1553
- <ref name="index-tertiary">
1554
- <a:documentation>The tertiary index term to be cross-referenced</a:documentation>
1555
- </ref>
1554
+ <optional>
1555
+ <ref name="index-secondary">
1556
+ <a:documentation>The secondary index term to be cross-referenced</a:documentation>
1557
+ </ref>
1558
+ </optional>
1559
+ <optional>
1560
+ <ref name="index-tertiary">
1561
+ <a:documentation>The tertiary index term to be cross-referenced</a:documentation>
1562
+ </ref>
1563
+ </optional>
1556
1564
  <element name="target">
1557
1565
  <a:documentation>The index term to be cross-referenced to</a:documentation>
1558
1566
  <oneOrMore>
@@ -1933,7 +1941,8 @@ or as the string "auto"</a:documentation>
1933
1941
  <define name="mathml">
1934
1942
  <a:documentation>Encoding of MathML: the official W3C MathML 4 grammar (namespace
1935
1943
  http://www.w3.org/1998/Math/MathML), via the metanorma wrapper in
1936
- grammars/mathml/. See grammars/mathml/README.adoc and basicdoc-models#35.</a:documentation>
1944
+ grammars/mathml/. See grammars/mathml/README.adoc, basicdoc-models#35,
1945
+ and the MathML 3 -&gt; 4 migration: basicdoc-models#39 / metanorma#585.</a:documentation>
1937
1946
  <externalRef href="metanorma-mathml.rng"/>
1938
1947
  </define>
1939
1948
  <define name="StemAttributes">
@@ -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.1.6 -->
3
+ <!-- VERSION v2.2.0 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.9
4
+ version: 3.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.