isodoc 3.7.0 → 3.7.1

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: 1704124a224846f711e07140b38b352fe8d9548465654168467b0d892c29867d
4
- data.tar.gz: eedf867e52f1ff13d2c7166a4bd9361ac432da5afc688c4d7bfa50f0f91bada5
3
+ metadata.gz: a85471023c45913439b8f282b641e3ef150cc8ae85a98abe0175308c4a0f66c7
4
+ data.tar.gz: de812d85b19a63560c65cf1920b25bed1f0bf53a1c94cd63cf45414c37d8b816
5
5
  SHA512:
6
- metadata.gz: 20ce7106f1eb73784cf58ef1ed0bf7bfc7f5bcd6c1a8495f4bec0b19326b70f7228fc2b0886abe4c98df19d2f42cc0456be55c6eba6d90c7806bbbff56bd5cd7
7
- data.tar.gz: ca9607aceeafd8d263a6cc779f6311d709b1c35c6be218ec6b0dee2193e86eb1cdc1725b0457d79c8967bcb27e6c4df4b062ca972960e96690e309ab7c9e9503
6
+ metadata.gz: b3c04391ab690ff67d9c2841158feb4c92f8f4f1e35fc62e6bf61daf64abd8fcec08193af1bdbff30d2bc4feec1994d75c1920c461e4ca0e38720ff8cebe1cf6
7
+ data.tar.gz: 77377cce8adc055116f91c972c6204c9aecd15a95df79c66b54ab07e78d7a2c0a1efa2e60262a8a1542b1f3c623da53b7f83631ce6a222e2107602ac6370039f
@@ -143,6 +143,11 @@ a.FootnoteRef, span.FootnoteRef {
143
143
  vertical-align: super;
144
144
  }
145
145
 
146
+ a.TableFootnoteRef, a.FootnoteRef, a.footnote-number,
147
+ sup a, a:has(> sup) {
148
+ vertical-align: baseline;
149
+ }
150
+
146
151
  .addition {
147
152
  color: blue;
148
153
  }
@@ -130,6 +130,10 @@ dl dd {
130
130
  grid-column-start: 2;
131
131
  }
132
132
 
133
+ dl:has(dt .stem) {
134
+ grid-template-columns: fit-content(8em) auto;
135
+ }
136
+
133
137
  b, strong {
134
138
  font-weight: bold;
135
139
  }
@@ -137,6 +137,18 @@ dl {
137
137
  }
138
138
  }
139
139
 
140
+ // metanorma-taste#150: a symbols definition list holds the AsciiMath *source*
141
+ // string in its dt (HTML renders math client-side via async MathJax, which never
142
+ // reflows the grid), so a long source blows out the max-content term column and
143
+ // pushes every definition far right. Cap the term column of stem-bearing dls so
144
+ // the term-to-definition gap stays bounded; plain/abbreviation dls keep
145
+ // max-content, which is correct for them. 8em is a crude, tunable ceiling.
146
+ // STOPGAP: remove this rule and restore plain max-content once HTML emits
147
+ // server-side MathML (the term column will then size to the rendered symbol).
148
+ dl:has(dt .stem) {
149
+ grid-template-columns: fit-content(8em) auto;
150
+ }
151
+
140
152
  b, strong {
141
153
  font-weight: bold;
142
154
  }
@@ -63,11 +63,59 @@ module IsoDoc
63
63
  bib = BibdataConfig.from_xml(
64
64
  "<metanorma>#{stripped.root.to_xml}</metanorma>",
65
65
  ).bibdata or return nil
66
- YAML.safe_load(bib.to_yaml, permitted_classes: [Date, Symbol],
67
- symbolize_names: true)
66
+ hash = YAML.safe_load(bib.to_yaml, permitted_classes: [Date, Symbol],
67
+ symbolize_names: true)
68
+ hash and fold_in_bibdata_ext(hash, stripped)
69
+ hash
68
70
  rescue StandardError => e
69
71
  warn "Failed to parse bibdata for Liquid template use: #{e.message}"
70
72
  nil
71
73
  end
74
+
75
+ # The Liquid `bibdata` object is built by round-tripping //bibdata through
76
+ # the Relaton object model, which represents bibliographic-item fields but
77
+ # not the Metanorma-document extension metadata under bibdata/ext
78
+ # (coverpage-image, innercoverpage-image, ...). Relaton drops those, so
79
+ # fold the raw ext subtree back in, using the same serialisation convention
80
+ # Relaton uses: element text -> :content, attributes -> sibling keys,
81
+ # repeated elements -> arrays, hyphens -> underscores (as in
82
+ # schema-version -> schema_version). Relaton-modelled keys win on collision;
83
+ # :ext is only populated when <ext> is present.
84
+ def fold_in_bibdata_ext(hash, stripped)
85
+ ext = stripped.at("//bibdata/ext") or return
86
+ raw = xml_element_hash(ext)
87
+ raw.is_a?(Hash) or return
88
+ modelled = hash[:ext].is_a?(Hash) ? hash[:ext] : {}
89
+ hash[:ext] = raw.merge(modelled)
90
+ end
91
+
92
+ # Generic Nokogiri element -> nested hash in Relaton's serialisation shape.
93
+ def xml_element_hash(node)
94
+ hash = {}
95
+ node.attribute_nodes.each { |a| hash[ext_hash_key(a.node_name)] = a.value }
96
+ children = node.element_children
97
+ if children.empty?
98
+ text = node.text.strip
99
+ hash[:content] = text unless text.empty?
100
+ else
101
+ children.each do |c|
102
+ add_ext_child(hash, ext_hash_key(c.node_name), xml_element_hash(c))
103
+ end
104
+ end
105
+ hash
106
+ end
107
+
108
+ def add_ext_child(hash, key, value)
109
+ if hash.key?(key)
110
+ hash[key] = [hash[key]] unless hash[key].is_a?(Array)
111
+ hash[key] << value
112
+ else
113
+ hash[key] = value
114
+ end
115
+ end
116
+
117
+ def ext_hash_key(name)
118
+ name.tr("-", "_").to_sym
119
+ end
72
120
  end
73
121
  end
@@ -51,7 +51,19 @@ module IsoDoc
51
51
 
52
52
  def sourcecode1(elem)
53
53
  ret1 = semx_fmt_dup(elem)
54
- b = ret1.at(ns(".//body")) and b.replace(b.children)
54
+ if (b = ret1.at(ns(".//body")))
55
+ # Remove formatting whitespace *preceding* the body (e.g. the newlines
56
+ # standoc emits around a <name> with inline markup). Once the body is
57
+ # unwrapped and the name removed, such stray whitespace would be lexed
58
+ # as leading blank lines of code. Whitespace after the body and the
59
+ # verbatim body content itself are untouched, so genuine code
60
+ # indentation is preserved.
61
+ b.parent.children.each do |c|
62
+ c == b and break
63
+ c.text? && c.text.strip.empty? and c.remove
64
+ end
65
+ b.replace(b.children)
66
+ end
55
67
  source_label(elem)
56
68
  source_highlight(ret1, elem["linenums"] == "true", elem["lang"])
57
69
  callouts(elem)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.7.0".freeze
2
+ VERSION = "3.7.1".freeze
3
3
  end
@@ -70,9 +70,19 @@ module IsoDoc
70
70
  elem_name)
71
71
  ret[:container] = @klass.get_clause_id(node) if opt[:container]
72
72
  ret[:value] = stripsemx(lbl)
73
+ t = asset_title(node) and ret[:title] = t
73
74
  ret
74
75
  end
75
76
 
77
+ # Caption of a numbered asset (its <name>, or a modspec requirement's
78
+ # <title>), semx-wrapped, so that xrefstyle=full can render
79
+ # "Table 3, caption" the way clauses render "Clause 6, Title". Returns nil
80
+ # when the asset has no caption, so anchor_xref_full falls back to short.
81
+ def asset_title(node)
82
+ n = node.at(ns("./name")) || node.at(ns("./title")) or return nil
83
+ semx(node, n.children.to_xml, n.name)
84
+ end
85
+
76
86
  include ::IsoDoc::XrefGen::Util
77
87
  end
78
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.