isodoc 3.1.6 → 3.1.7

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/css_border_parser.rb +229 -0
  3. data/lib/isodoc/css_border_parser_vars.rb +211 -0
  4. data/lib/isodoc/function/blocks.rb +1 -1
  5. data/lib/isodoc/function/blocks_example_note.rb +0 -2
  6. data/lib/isodoc/function/footnotes.rb +2 -1
  7. data/lib/isodoc/function/section.rb +6 -2
  8. data/lib/isodoc/function/section_titles.rb +2 -2
  9. data/lib/isodoc/function/terms.rb +1 -1
  10. data/lib/isodoc/function/to_word_html.rb +2 -0
  11. data/lib/isodoc/function/utils.rb +6 -15
  12. data/lib/isodoc/html_function/postprocess.rb +1 -2
  13. data/lib/isodoc/html_function/postprocess_cover.rb +14 -5
  14. data/lib/isodoc/init.rb +12 -3
  15. data/lib/isodoc/presentation_function/autonum.rb +4 -3
  16. data/lib/isodoc/presentation_function/block.rb +14 -1
  17. data/lib/isodoc/presentation_function/concepts.rb +17 -11
  18. data/lib/isodoc/presentation_function/docid.rb +2 -1
  19. data/lib/isodoc/presentation_function/erefs.rb +1 -1
  20. data/lib/isodoc/presentation_function/image.rb +1 -2
  21. data/lib/isodoc/presentation_function/inline.rb +13 -7
  22. data/lib/isodoc/presentation_function/math.rb +19 -23
  23. data/lib/isodoc/presentation_function/section.rb +11 -10
  24. data/lib/isodoc/presentation_function/terms.rb +34 -12
  25. data/lib/isodoc/presentation_function/title.rb +1 -2
  26. data/lib/isodoc/presentation_function/xrefs.rb +2 -2
  27. data/lib/isodoc/presentation_xml_convert.rb +3 -0
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_function/comments.rb +1 -2
  30. data/lib/isodoc/word_function/inline.rb +1 -1
  31. data/lib/isodoc/word_function/postprocess.rb +0 -1
  32. data/lib/isodoc/xref/xref_gen_seq.rb +5 -30
  33. data/lib/isodoc/xref/xref_sect_asset.rb +44 -0
  34. data/lib/isodoc/xref/xref_sect_gen.rb +39 -37
  35. data/lib/isodoc/xref/xref_util.rb +28 -1
  36. data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
  37. data/lib/isodoc-yaml/i18n-de.yaml +1 -0
  38. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  39. data/lib/isodoc-yaml/i18n-es.yaml +1 -0
  40. data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
  41. data/lib/isodoc-yaml/i18n-ja.yaml +1 -0
  42. data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
  43. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  44. data/lib/isodoc.rb +1 -1
  45. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9537662f7ab02f4c50797c307b3f0ed4ae1f1d1627b70e3bd61f58bdfc9d30c
4
- data.tar.gz: a9582a5ba998a8807e6da33a908be1523a362d8be41dd4964efea3263d07a7cf
3
+ metadata.gz: a295da0c0143ef7732aca192d4ebc1e9eb7c0b4ec6b515bb00609cd7b9dce1e2
4
+ data.tar.gz: 33b46c1df1e837cdd1df7034f434bb7740bdb720d4309a663e51368df5898998
5
5
  SHA512:
6
- metadata.gz: cea0eec386e6300c4b993d54b81f634625973a92363effaba6ca5ebcc62bf9f9bb847a714264b4909bd001020ea0ed47bf5503f494860b6af9b9ec83482ea9ab
7
- data.tar.gz: 61678783412c3bc1fd6525dd656750f152eb18868cb4beabbf24ad963a63176b86fe90889844e6b3527cbc47637d49c51e03982991911f222acf8505277484b8
6
+ metadata.gz: 12e4328d0d97cec33a1fe8a3afb339f6488e91d410c5cd40ff85ae46e571e8575ef50929d5756bfaa24604cdf1545ffef061c1429a80d1cb7c5af7527ce3be23
7
+ data.tar.gz: e55fc19631f6075ca61f459bb5026a435ff6eadc2f604fdd269abebf1fe4153a975fb095061b289371c08ba76d271e868b7fe2a1f3fc0b9a53bd50c5671b2a7f
@@ -0,0 +1,229 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "css_border_parser_vars"
4
+
5
+ module IsoDoc
6
+ # CssBorderParser provides functionality to parse CSS border shorthand
7
+ # properties # and break them down into atomic CSS attributes.
8
+ class CssBorderParser
9
+ # BorderParser class handles the parsing of CSS border properties
10
+ class BorderParser
11
+ def initialize; end # No initialization needed
12
+
13
+ # Parse CSS and extract border properties
14
+ #
15
+ # @param css_string [String] CSS content to parse
16
+ # @return [Hash] Parsed border properties organized by selector
17
+ def parse(css_string)
18
+ results = {}
19
+ rule_sets = extract_rule_sets(css_string)
20
+ rule_sets.each do |selector, declarations|
21
+ results[selector] = {}
22
+ process_border_properties(declarations, results[selector])
23
+ store_non_border_properties(declarations, results[selector])
24
+ end
25
+
26
+ results
27
+ end
28
+
29
+ # Parse a CSS declaration string
30
+ #
31
+ # @param css_declaration [String] CSS declaration string
32
+ # (can contain multiple declarations)
33
+ # @return [Hash] Parsed border properties
34
+ def parse_declaration(css_declaration)
35
+ result = {}
36
+ declarations = css_declaration.split(";").each_with_object({}) do |d, m|
37
+ d = d.strip
38
+ d.empty? and next
39
+ property, value = d.split(":", 2).map(&:strip)
40
+ m[property] = value
41
+ end
42
+ process_border_properties(declarations, result)
43
+ store_non_border_properties(declarations, result)
44
+ result
45
+ end
46
+
47
+ # Generate a CSS string from parsed properties
48
+ #
49
+ # @param parsed_properties [Hash] Parsed CSS properties
50
+ # @param format [Symbol] Output format (:inline, :rule_set)
51
+ # @param selector [String] CSS selector (only used with :rule_set format)
52
+ # @return [String] CSS string representation
53
+ def to_css_string(parsed_properties, format: :inline, selector: nil)
54
+ css_parts = []
55
+ parsed_properties.each do |property_group, components|
56
+ property_group == "other_properties" and next
57
+ if property_group == "border"
58
+ components.each do |property_type, value|
59
+ css_parts << "border-#{property_type}: #{value};"
60
+ end
61
+ elsif property_group.start_with?("border-")
62
+ # direction-specific border properties
63
+ direction = property_group.sub("border-", "")
64
+ components.each do |property_type, value|
65
+ css_parts << "border-#{direction}-#{property_type}: #{value};"
66
+ end
67
+ end
68
+ end
69
+ # non-border properties
70
+ parsed_properties["other_properties"]&.each do |property, value|
71
+ css_parts << "#{property}: #{value};"
72
+ end
73
+ format_properties(format, css_parts, selector)
74
+ end
75
+
76
+ private
77
+
78
+ def format_properties(format, css_parts, selector)
79
+ case format
80
+ when :inline
81
+ css_parts.join(" ")
82
+ when :rule_set
83
+ selector = selector || "selector"
84
+ "#{selector} {\n #{css_parts.join("\n ")}\n}"
85
+ else
86
+ css_parts.join(" ")
87
+ end
88
+ end
89
+
90
+ # Extract rule sets from CSS string
91
+ def extract_rule_sets(css_string)
92
+ rule_sets = {}
93
+ css_string = css_string.gsub(/\/\*.*?\*\//m, "") # Remove comments
94
+ css_string.scan(/([^{]+)\{([^}]+)\}/m) do |selector, declarations|
95
+ selector = selector.strip
96
+ declarations_hash = {} # Extract declarations
97
+ declarations.scan(/([^:;]+):([^;]+);?/) do |property, value|
98
+ declarations_hash[property.strip] = value.strip
99
+ end
100
+ rule_sets[selector] = declarations_hash
101
+ end
102
+ rule_sets
103
+ end
104
+
105
+ # Process border properties from declarations
106
+ def process_border_properties(declarations, result_hash)
107
+ # Process general border property
108
+ process_border_property(declarations, result_hash, "border")
109
+ # Process direction-specific border properties
110
+ ["top", "right", "bottom", "left"].each do |direction|
111
+ process_border_property(declarations, result_hash,
112
+ "border-#{direction}")
113
+ end
114
+ # Process individual property groups
115
+ process_individual_properties(declarations, result_hash)
116
+ end
117
+
118
+ # Store non-border properties
119
+ def store_non_border_properties(declarations, result_hash)
120
+ # Initialize other_properties hash if it doesn't exist
121
+ result_hash["other_properties"] ||= {}
122
+
123
+ # Identify and store non-border properties
124
+ declarations.each do |property, value|
125
+ # Skip border-related properties
126
+ next if property == "border"
127
+ next if property.start_with?("border-")
128
+
129
+ # Store non-border property
130
+ result_hash["other_properties"][property] = value
131
+ end
132
+ end
133
+
134
+ # Process a specific border property
135
+ def process_border_property(declarations, result_hash, prefix)
136
+ # Check if the property exists
137
+ if declarations.key?(prefix)
138
+ # Parse the border shorthand value
139
+ components = parse_border_value(declarations[prefix])
140
+ result_hash[prefix] = components
141
+ end
142
+ end
143
+
144
+ # Parse border shorthand value into components
145
+ def parse_border_value(value)
146
+ components = {
147
+ "width" => DEFAULT_VALUES["width"],
148
+ "style" => DEFAULT_VALUES["style"],
149
+ "color" => DEFAULT_VALUES["color"],
150
+ }
151
+ value.split(/\s+/).each do |part|
152
+ if width?(part) then components["width"] = part
153
+ elsif style?(part) then components["style"] = part
154
+ elsif color?(part)
155
+ components["color"] = convert_color_to_rgb(part)
156
+ end
157
+ end
158
+ components
159
+ end
160
+
161
+ # Convert a color name to its RGB hex value
162
+ def convert_color_to_rgb(color)
163
+ color_lower = color.downcase
164
+ # Return the hex value if the color is a named color
165
+ COLOR_MAP.key?(color_lower) and return COLOR_MAP[color_lower]
166
+ # Return the original value if it's not a named color
167
+ # or is already in a valid color format
168
+ color
169
+ end
170
+
171
+ # Process individual property groups
172
+ def process_individual_properties(declarations, result)
173
+ # Check for individual property groups
174
+ individual_props = {}
175
+ ["width", "style", "color"].each do |type|
176
+ name = "border-#{type}"
177
+ declarations.key?(name) or next
178
+ # If we don't have a border property yet, create it
179
+ result["border"] ||= {}
180
+ result["border"][type] = if type == "color"
181
+ convert_color_to_rgb(declarations[name])
182
+ else
183
+ declarations[name]
184
+ end
185
+ individual_props[type] = true
186
+ end
187
+ process_individual_properties_cleanup(individual_props, declarations,
188
+ result)
189
+ end
190
+
191
+ # If we're only dealing with individual properties (not a shorthand),
192
+ # only include the properties that were explicitly specified
193
+ def process_individual_properties_cleanup(props, declarations, result)
194
+ if props.size.positive? && !declarations.key?("border")
195
+ # Remove default values for properties that weren't specified
196
+ ["width", "style", "color"].each do |type|
197
+ props[type] or result["border"].delete(type)
198
+ end
199
+ end
200
+ end
201
+
202
+ # Check if a value is a border width
203
+ def width?(value)
204
+ return true if BORDER_WIDTHS.include?(value)
205
+ return true if /^(\d+(\.\d+)?)(px|em|rem|%|pt|pc|in|cm|mm|ex|ch|vw|vh|vmin|vmax)$/.match?(value)
206
+ return true if /^\d+$/.match?(value)
207
+
208
+ false
209
+ end
210
+
211
+ # Check if a value is a border style
212
+ def style?(value)
213
+ BORDER_STYLES.include?(value)
214
+ end
215
+
216
+ # Check if a value is a color
217
+ def color?(value)
218
+ return true if COLOR_KEYWORDS.include?(value.downcase)
219
+ return true if /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.match?(value)
220
+ return true if /^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/.match?(value)
221
+ return true if /^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*[\d.]+\s*\)$/.match?(value)
222
+ return true if /^hsl\(\s*\d+\s*,\s*[\d.]+%\s*,\s*[\d.]+%\s*\)$/.match?(value)
223
+ return true if /^hsla\(\s*\d+\s*,\s*[\d.]+%\s*,\s*[\d.]+%\s*,\s*[\d.]+\s*\)$/.match?(value)
224
+
225
+ false
226
+ end
227
+ end
228
+ end
229
+ end
@@ -0,0 +1,211 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IsoDoc
4
+ class CssBorderParser
5
+ class BorderParser
6
+ # Default values according to CSS specifications
7
+ DEFAULT_VALUES = {
8
+ "width" => "medium",
9
+ "style" => "none",
10
+ "color" => "currentColor",
11
+ }.freeze
12
+
13
+ # CSS border width values
14
+ BORDER_WIDTHS = ["thin", "medium", "thick"].freeze
15
+
16
+ # CSS border style values
17
+ BORDER_STYLES = [
18
+ "none", "hidden", "dotted", "dashed", "solid", "double",
19
+ "groove", "ridge", "inset", "outset"
20
+ ].freeze
21
+
22
+ # CSS color keywords
23
+ COLOR_KEYWORDS = [
24
+ "black", "silver", "gray", "white", "maroon", "red", "purple",
25
+ "fuchsia", "green", "lime", "olive", "yellow", "navy", "blue",
26
+ "teal", "aqua", "orange", "aliceblue", "antiquewhite", "aquamarine",
27
+ "azure", "beige", "bisque", "blanchedalmond", "blueviolet", "brown",
28
+ "burlywood", "cadetblue", "chartreuse", "chocolate", "coral",
29
+ "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue",
30
+ "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey",
31
+ "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange",
32
+ "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue",
33
+ "darkslategray", "darkslategrey", "darkturquoise", "darkviolet",
34
+ "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue",
35
+ "firebrick", "floralwhite", "forestgreen", "gainsboro", "ghostwhite",
36
+ "gold", "goldenrod", "greenyellow", "grey", "honeydew", "hotpink",
37
+ "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush",
38
+ "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan",
39
+ "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey",
40
+ "lightpink", "lightsalmon", "lightseagreen", "lightskyblue",
41
+ "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow",
42
+ "limegreen", "linen", "magenta", "mediumaquamarine", "mediumblue",
43
+ "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue",
44
+ "mediumspringgreen", "mediumturquoise", "mediumvioletred",
45
+ "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite",
46
+ "oldlace", "olivedrab", "orangered", "orchid", "palegoldenrod",
47
+ "palegreen", "paleturquoise", "palevioletred", "papayawhip",
48
+ "peachpuff", "peru", "pink", "plum", "powderblue", "rosybrown",
49
+ "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen",
50
+ "seashell", "sienna", "skyblue", "slateblue", "slategray",
51
+ "slategrey", "snow", "springgreen", "steelblue", "tan", "thistle",
52
+ "tomato", "turquoise", "violet", "wheat", "whitesmoke",
53
+ "yellowgreen", "transparent", "currentColor"
54
+ ].freeze
55
+
56
+ # Mapping of CSS color names to RGB hex values
57
+ COLOR_MAP = {
58
+ "black" => "#000000",
59
+ "silver" => "#C0C0C0",
60
+ "gray" => "#808080",
61
+ "white" => "#FFFFFF",
62
+ "maroon" => "#800000",
63
+ "red" => "#FF0000",
64
+ "purple" => "#800080",
65
+ "fuchsia" => "#FF00FF",
66
+ "green" => "#008000",
67
+ "lime" => "#00FF00",
68
+ "olive" => "#808000",
69
+ "yellow" => "#FFFF00",
70
+ "navy" => "#000080",
71
+ "blue" => "#0000FF",
72
+ "teal" => "#008080",
73
+ "aqua" => "#00FFFF",
74
+ "orange" => "#FFA500",
75
+ "aliceblue" => "#F0F8FF",
76
+ "antiquewhite" => "#FAEBD7",
77
+ "aquamarine" => "#7FFFD4",
78
+ "azure" => "#F0FFFF",
79
+ "beige" => "#F5F5DC",
80
+ "bisque" => "#FFE4C4",
81
+ "blanchedalmond" => "#FFEBCD",
82
+ "blueviolet" => "#8A2BE2",
83
+ "brown" => "#A52A2A",
84
+ "burlywood" => "#DEB887",
85
+ "cadetblue" => "#5F9EA0",
86
+ "chartreuse" => "#7FFF00",
87
+ "chocolate" => "#D2691E",
88
+ "coral" => "#FF7F50",
89
+ "cornflowerblue" => "#6495ED",
90
+ "cornsilk" => "#FFF8DC",
91
+ "crimson" => "#DC143C",
92
+ "cyan" => "#00FFFF",
93
+ "darkblue" => "#00008B",
94
+ "darkcyan" => "#008B8B",
95
+ "darkgoldenrod" => "#B8860B",
96
+ "darkgray" => "#A9A9A9",
97
+ "darkgreen" => "#006400",
98
+ "darkgrey" => "#A9A9A9",
99
+ "darkkhaki" => "#BDB76B",
100
+ "darkmagenta" => "#8B008B",
101
+ "darkolivegreen" => "#556B2F",
102
+ "darkorange" => "#FF8C00",
103
+ "darkorchid" => "#9932CC",
104
+ "darkred" => "#8B0000",
105
+ "darksalmon" => "#E9967A",
106
+ "darkseagreen" => "#8FBC8F",
107
+ "darkslateblue" => "#483D8B",
108
+ "darkslategray" => "#2F4F4F",
109
+ "darkslategrey" => "#2F4F4F",
110
+ "darkturquoise" => "#00CED1",
111
+ "darkviolet" => "#9400D3",
112
+ "deeppink" => "#FF1493",
113
+ "deepskyblue" => "#00BFFF",
114
+ "dimgray" => "#696969",
115
+ "dimgrey" => "#696969",
116
+ "dodgerblue" => "#1E90FF",
117
+ "firebrick" => "#B22222",
118
+ "floralwhite" => "#FFFAF0",
119
+ "forestgreen" => "#228B22",
120
+ "gainsboro" => "#DCDCDC",
121
+ "ghostwhite" => "#F8F8FF",
122
+ "gold" => "#FFD700",
123
+ "goldenrod" => "#DAA520",
124
+ "greenyellow" => "#ADFF2F",
125
+ "grey" => "#808080",
126
+ "honeydew" => "#F0FFF0",
127
+ "hotpink" => "#FF69B4",
128
+ "indianred" => "#CD5C5C",
129
+ "indigo" => "#4B0082",
130
+ "ivory" => "#FFFFF0",
131
+ "khaki" => "#F0E68C",
132
+ "lavender" => "#E6E6FA",
133
+ "lavenderblush" => "#FFF0F5",
134
+ "lawngreen" => "#7CFC00",
135
+ "lemonchiffon" => "#FFFACD",
136
+ "lightblue" => "#ADD8E6",
137
+ "lightcoral" => "#F08080",
138
+ "lightcyan" => "#E0FFFF",
139
+ "lightgoldenrodyellow" => "#FAFAD2",
140
+ "lightgray" => "#D3D3D3",
141
+ "lightgreen" => "#90EE90",
142
+ "lightgrey" => "#D3D3D3",
143
+ "lightpink" => "#FFB6C1",
144
+ "lightsalmon" => "#FFA07A",
145
+ "lightseagreen" => "#20B2AA",
146
+ "lightskyblue" => "#87CEFA",
147
+ "lightslategray" => "#778899",
148
+ "lightslategrey" => "#778899",
149
+ "lightsteelblue" => "#B0C4DE",
150
+ "lightyellow" => "#FFFFE0",
151
+ "limegreen" => "#32CD32",
152
+ "linen" => "#FAF0E6",
153
+ "magenta" => "#FF00FF",
154
+ "mediumaquamarine" => "#66CDAA",
155
+ "mediumblue" => "#0000CD",
156
+ "mediumorchid" => "#BA55D3",
157
+ "mediumpurple" => "#9370DB",
158
+ "mediumseagreen" => "#3CB371",
159
+ "mediumslateblue" => "#7B68EE",
160
+ "mediumspringgreen" => "#00FA9A",
161
+ "mediumturquoise" => "#48D1CC",
162
+ "mediumvioletred" => "#C71585",
163
+ "midnightblue" => "#191970",
164
+ "mintcream" => "#F5FFFA",
165
+ "mistyrose" => "#FFE4E1",
166
+ "moccasin" => "#FFE4B5",
167
+ "navajowhite" => "#FFDEAD",
168
+ "oldlace" => "#FDF5E6",
169
+ "olivedrab" => "#6B8E23",
170
+ "orangered" => "#FF4500",
171
+ "orchid" => "#DA70D6",
172
+ "palegoldenrod" => "#EEE8AA",
173
+ "palegreen" => "#98FB98",
174
+ "paleturquoise" => "#AFEEEE",
175
+ "palevioletred" => "#DB7093",
176
+ "papayawhip" => "#FFEFD5",
177
+ "peachpuff" => "#FFDAB9",
178
+ "peru" => "#CD853F",
179
+ "pink" => "#FFC0CB",
180
+ "plum" => "#DDA0DD",
181
+ "powderblue" => "#B0E0E6",
182
+ "rosybrown" => "#BC8F8F",
183
+ "royalblue" => "#4169E1",
184
+ "saddlebrown" => "#8B4513",
185
+ "salmon" => "#FA8072",
186
+ "sandybrown" => "#F4A460",
187
+ "seagreen" => "#2E8B57",
188
+ "seashell" => "#FFF5EE",
189
+ "sienna" => "#A0522D",
190
+ "skyblue" => "#87CEEB",
191
+ "slateblue" => "#6A5ACD",
192
+ "slategray" => "#708090",
193
+ "slategrey" => "#708090",
194
+ "snow" => "#FFFAFA",
195
+ "springgreen" => "#00FF7F",
196
+ "steelblue" => "#4682B4",
197
+ "tan" => "#D2B48C",
198
+ "thistle" => "#D8BFD8",
199
+ "tomato" => "#FF6347",
200
+ "turquoise" => "#40E0D0",
201
+ "violet" => "#EE82EE",
202
+ "wheat" => "#F5DEB3",
203
+ "whitesmoke" => "#F5F5F5",
204
+ "yellowgreen" => "#9ACD32",
205
+ # Special values that should not be converted
206
+ "transparent" => "transparent",
207
+ "currentColor" => "currentColor",
208
+ }.freeze
209
+ end
210
+ end
211
+ end
@@ -157,7 +157,7 @@ module IsoDoc
157
157
 
158
158
  def passthrough_parse(node, out)
159
159
  node["formats"] &&
160
- !(node["formats"].split(" ").include? @format.to_s) and return
160
+ !(node["formats"].split.include? @format.to_s) and return
161
161
  out.passthrough node.text
162
162
  end
163
163
 
@@ -78,7 +78,6 @@ module IsoDoc
78
78
  name and p.span class: "note_label" do |s|
79
79
  name.children.each { |n| parse(n, s) }
80
80
  end
81
- #insert_tab(p, 1) # TODO to Presentation XML
82
81
  children_parse(para, p)
83
82
  end
84
83
  para.xpath("./following-sibling::*").each { |n| parse(n, div) }
@@ -90,7 +89,6 @@ module IsoDoc
90
89
  p.span class: "note_label" do |s|
91
90
  name.remove.children.each { |n| parse(n, s) }
92
91
  end
93
- #insert_tab(p, 1) # TODO to Presentation XML
94
92
  end
95
93
  children_parse(node, div)
96
94
  end
@@ -30,7 +30,8 @@ module IsoDoc
30
30
  end
31
31
 
32
32
  def update_table_fn_body_ref(fnote, table, reference)
33
- fnbody = table.at(ns(".//fmt-fn-body[@id = '#{fnote['target']}']")) or return
33
+ fnbody = table.at(ns(".//fmt-fn-body[@id = '#{fnote['target']}']")) or
34
+ return
34
35
  fnbody["reference"] = reference
35
36
  fnbody["is_table"] = true
36
37
  sup = fnbody.at(ns(".//fmt-fn-label/sup")) and sup.replace(sup.children)
@@ -41,6 +41,10 @@ module IsoDoc
41
41
  end
42
42
  end
43
43
 
44
+ def appendix_parse(isoxml, out)
45
+ clause_parse(isoxml, out)
46
+ end
47
+
44
48
  def indexsect(node, out)
45
49
  clause_parse(node, out)
46
50
  end
@@ -173,9 +177,9 @@ module IsoDoc
173
177
  end
174
178
  end
175
179
 
176
- def is_clause?(name)
180
+ def clause?(name)
177
181
  %w(clause references definitions terms foreword introduction abstract
178
- acknowledgements indexsect).include? name
182
+ executivesummary acknowledgements indexsect).include? name
179
183
  end
180
184
 
181
185
  def single_term_clause?(elem)
@@ -19,7 +19,7 @@ module IsoDoc
19
19
  end
20
20
 
21
21
  def sections_names
22
- %w[clause annex terms references definitions
22
+ %w[clause annex terms references definitions executivesummary
23
23
  acknowledgements introduction abstract foreword appendix]
24
24
  end
25
25
 
@@ -53,7 +53,7 @@ module IsoDoc
53
53
 
54
54
  def clause_title_depth(node, title)
55
55
  depth = title["depth"] if title && title["depth"]
56
- depth = node.ancestors(sections_names.join(", ")).size + 1 unless depth
56
+ depth ||= node.ancestors(sections_names.join(", ")).size + 1
57
57
  depth
58
58
  end
59
59
 
@@ -26,7 +26,7 @@ module IsoDoc
26
26
  def semx_admitted_term_parse(node, out); end
27
27
 
28
28
  def admitted_term_parse(node, out)
29
- node.children.each do |c|
29
+ node.children.each do |c|
30
30
  if c.name == "p"
31
31
  out.p class: "AltTerms", style: "text-align:left;" do |p|
32
32
  c.children.each { |c1| parse(c1, p) }
@@ -74,6 +74,7 @@ module IsoDoc
74
74
  when "executivesummary" then executivesummary e, out
75
75
  when "acknowledgements" then acknowledgements e, out
76
76
  when "annex" then annex e, out
77
+ when "appendix" then appendix e, out
77
78
  when "definitions" then symbols_abbrevs e, out
78
79
  when "indexsect" then indexsect e, out
79
80
  when "references"
@@ -136,6 +137,7 @@ module IsoDoc
136
137
  when "fmt-stem" then stem_parse(node, out)
137
138
  when "stem" then semx_stem_parse(node, out)
138
139
  when "clause" then clause_parse(node, out)
140
+ when "appendix" then appendix_parse(node, out)
139
141
  when "xref" then semx_xref_parse(node, out)
140
142
  when "fmt-xref" then xref_parse(node, out)
141
143
  when "eref" then semx_eref_parse(node, out)
@@ -76,26 +76,17 @@ module IsoDoc
76
76
  .sub(%r{ xmlns="http://www.w3.org/1999/xhtml"}, ""))
77
77
  end
78
78
 
79
- CLAUSE_ANCESTOR =
80
- ".//ancestor::*[local-name() = 'annex' or " \
81
- "local-name() = 'definitions' or " \
82
- "local-name() = 'acknowledgements' or local-name() = 'term' or " \
83
- "local-name() = 'appendix' or local-name() = 'foreword' or " \
84
- "local-name() = 'introduction' or local-name() = 'terms' or " \
85
- "local-name() = 'clause' or local-name() = 'references']/@id".freeze
79
+ CLAUSE_ANCESTOR = <<~XPATH.strip.freeze
80
+ .//ancestor::*[local-name() = 'annex' or local-name() = 'definitions' or local-name() = 'executivesummary' or local-name() = 'acknowledgements' or local-name() = 'term' or local-name() = 'appendix' or local-name() = 'foreword' or local-name() = 'introduction' or local-name() = 'terms' or local-name() = 'clause' or local-name() = 'references']/@id
81
+ XPATH
86
82
 
87
83
  def get_clause_id(node)
88
84
  node.xpath(CLAUSE_ANCESTOR)&.last&.text || nil
89
85
  end
90
86
 
91
- NOTE_CONTAINER_ANCESTOR =
92
- ".//ancestor::*[local-name() = 'annex' or " \
93
- "local-name() = 'foreword' or local-name() = 'appendix' or " \
94
- "local-name() = 'introduction' or local-name() = 'terms' or " \
95
- "local-name() = 'acknowledgements' or local-name() = 'term' or " \
96
- "local-name() = 'clause' or local-name() = 'references' or " \
97
- "local-name() = 'figure' or local-name() = 'formula' or " \
98
- "local-name() = 'table' or local-name() = 'example']/@id".freeze
87
+ NOTE_CONTAINER_ANCESTOR = <<~XPATH.strip.freeze
88
+ .//ancestor::*[local-name() = 'annex' or local-name() = 'foreword' or local-name() = 'appendix' or local-name() = 'introduction' or local-name() = 'terms' or local-name() = 'acknowledgements' or local-name() = 'executivesummary' or local-name() = 'term' or local-name() = 'clause' or local-name() = 'references' or local-name() = 'figure' or local-name() = 'formula' or local-name() = 'table' or local-name() = 'example']/@id
89
+ XPATH
99
90
 
100
91
  # no recursion on references
101
92
  def get_note_container_id(node, type)
@@ -26,8 +26,7 @@ module IsoDoc
26
26
 
27
27
  def html_cleanup(html)
28
28
  html = term_header(html_footnote_filter(html_preface(htmlstyle(html))))
29
- #html = footnote_format(footnote_backlinks(html))
30
- html = (footnote_backlinks(html))
29
+ html = footnote_backlinks(html)
31
30
  html = mathml(html_list_clean(remove_placeholder_paras(html)))
32
31
  html_toc(heading_anchors(sourcecode_cleanup(html)))
33
32
  end
@@ -82,7 +82,6 @@ module IsoDoc
82
82
  def html_cover(docxml)
83
83
  doc = to_xhtml_fragment(File.read(@htmlcoverpage, encoding: "UTF-8"))
84
84
  d = docxml.at('//div[@class="title-section"]')
85
- #d.children.first.add_previous_sibling(
86
85
  d.add_first_child(
87
86
  populate_template(doc.to_xml(encoding: "US-ASCII"), :html),
88
87
  )
@@ -91,7 +90,6 @@ module IsoDoc
91
90
  def html_intro(docxml)
92
91
  doc = to_xhtml_fragment(File.read(@htmlintropage, encoding: "UTF-8"))
93
92
  d = docxml.at('//div[@class="prefatory-section"]')
94
- #d.children.first.add_previous_sibling(
95
93
  d.add_first_child(
96
94
  populate_template(doc.to_xml(encoding: "US-ASCII"), :html),
97
95
  )
@@ -180,9 +178,20 @@ module IsoDoc
180
178
  MATHJAX = <<~"MATHJAX".freeze
181
179
  <script type="text/x-mathjax-config">
182
180
  MathJax.Hub.Config({
183
- "HTML-CSS": { preferredFont: "STIX" },
184
- asciimath2jax: { delimiters: [['OPEN', 'CLOSE']] }
185
- });
181
+ "HTML-CSS": {
182
+ preferredFont: "STIX",
183
+ linebreaks: {
184
+ automatic: true,
185
+ width: "container" // or specify something like "90%"/"30em"
186
+ }
187
+ },
188
+ MathML: {
189
+ linebreaks: {
190
+ automatic: true
191
+ }
192
+ },
193
+ asciimath2jax: { delimiters: [['(#(', ')#)']] }
194
+ });
186
195
  </script>
187
196
  <script src="#{MATHJAX_ADDR}?config=MML_HTMLorMML-full" async="async"></script>
188
197
  MATHJAX