isodoc 3.1.6 → 3.1.9
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 +4 -4
- data/lib/isodoc/css_border_parser.rb +229 -0
- data/lib/isodoc/css_border_parser_vars.rb +211 -0
- data/lib/isodoc/function/blocks.rb +1 -1
- data/lib/isodoc/function/blocks_example_note.rb +0 -2
- data/lib/isodoc/function/footnotes.rb +4 -3
- data/lib/isodoc/function/inline.rb +1 -0
- data/lib/isodoc/function/lists.rb +0 -15
- data/lib/isodoc/function/section.rb +6 -2
- data/lib/isodoc/function/section_titles.rb +2 -2
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/terms.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +4 -1
- data/lib/isodoc/function/utils.rb +6 -15
- data/lib/isodoc/html_function/postprocess.rb +1 -2
- data/lib/isodoc/html_function/postprocess_cover.rb +14 -5
- data/lib/isodoc/init.rb +12 -3
- data/lib/isodoc/presentation_function/autonum.rb +4 -3
- data/lib/isodoc/presentation_function/block.rb +50 -10
- data/lib/isodoc/presentation_function/concepts.rb +19 -13
- data/lib/isodoc/presentation_function/docid.rb +2 -1
- data/lib/isodoc/presentation_function/erefs.rb +1 -2
- data/lib/isodoc/presentation_function/footnotes.rb +4 -4
- data/lib/isodoc/presentation_function/ids.rb +79 -0
- data/lib/isodoc/presentation_function/image.rb +1 -2
- data/lib/isodoc/presentation_function/inline.rb +13 -7
- data/lib/isodoc/presentation_function/math.rb +19 -23
- data/lib/isodoc/presentation_function/refs.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +11 -10
- data/lib/isodoc/presentation_function/terms.rb +50 -21
- data/lib/isodoc/presentation_function/title.rb +1 -3
- data/lib/isodoc/presentation_function/xrefs.rb +2 -2
- data/lib/isodoc/presentation_xml_convert.rb +3 -75
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/comments.rb +1 -2
- data/lib/isodoc/word_function/footnotes.rb +0 -29
- data/lib/isodoc/word_function/inline.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +0 -1
- data/lib/isodoc/xref/xref_gen_seq.rb +5 -30
- data/lib/isodoc/xref/xref_sect_asset.rb +44 -0
- data/lib/isodoc/xref/xref_sect_gen.rb +39 -37
- data/lib/isodoc/xref/xref_util.rb +28 -1
- data/lib/isodoc-yaml/i18n-ar.yaml +1 -0
- data/lib/isodoc-yaml/i18n-de.yaml +1 -0
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-es.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ja.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aad761a973bdff1849d666ab902b4964b557b26fb145deffb180aa665f411d11
|
4
|
+
data.tar.gz: 1f0ede0902421b11b89e8caf6034e17e13dc5b8639c0bfaa435ad3cb1f609f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e86d05bd30c8c3f4ff3299c82af79bbde4bdf4018aab90c635808fd66c88ee04d20384c87d42b292a888acf72114ff66ba250af69628e83f58378f4b48daf12e
|
7
|
+
data.tar.gz: fa112ae3e51c7b2045f93e387f60541c94a7771eb38a74b1d311102ba376e84aa1e7fc3ed0dc12599b8ffd4b6270677c4b85502398effbab970f7efd6103fe1e
|
@@ -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
|
@@ -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
|
@@ -3,7 +3,7 @@ module IsoDoc
|
|
3
3
|
module Footnotes
|
4
4
|
def make_table_footnote_link(out, fnid, node)
|
5
5
|
attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
|
6
|
-
sup = node.at(ns("
|
6
|
+
sup = node.at(ns(".//sup")) and sup.replace(sup.children)
|
7
7
|
out.a **attrs do |a|
|
8
8
|
children_parse(node, a)
|
9
9
|
end
|
@@ -30,10 +30,11 @@ 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
|
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
|
-
sup = fnbody.at(ns(".//fmt-fn-label
|
37
|
+
sup = fnbody.at(ns(".//fmt-fn-label//sup")) and sup.replace(sup.children)
|
37
38
|
fnbody.xpath(ns(".//fmt-fn-label")).each do |s|
|
38
39
|
s["class"] = "TableFootnoteRef"
|
39
40
|
s.name = "span"
|
@@ -34,21 +34,6 @@ module IsoDoc
|
|
34
34
|
OL_STYLE[type.to_sym]
|
35
35
|
end
|
36
36
|
|
37
|
-
# We don't really want users to specify type of ordered list;
|
38
|
-
# we will use a fixed hierarchy as practiced by ISO (though not
|
39
|
-
# fully spelled out): a) 1) i) A) I)
|
40
|
-
# Fallback, this is now being done in Presentation XML
|
41
|
-
# KILL
|
42
|
-
def ol_depthx(node)
|
43
|
-
depth = node.ancestors("ul, ol").size + 1
|
44
|
-
type = :alphabet
|
45
|
-
type = :arabic if [2, 7].include? depth
|
46
|
-
type = :roman if [3, 8].include? depth
|
47
|
-
type = :alphabet_upper if [4, 9].include? depth
|
48
|
-
type = :roman_upper if [5, 10].include? depth
|
49
|
-
ol_style(type)
|
50
|
-
end
|
51
|
-
|
52
37
|
def ol_attrs(node)
|
53
38
|
{ # type: node["type"] ? ol_style(node["type"].to_sym) : ol_depth(node),
|
54
39
|
type: ol_style(node["type"]&.to_sym),
|
@@ -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
|
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
|
56
|
+
depth ||= node.ancestors(sections_names.join(", ")).size + 1
|
57
57
|
depth
|
58
58
|
end
|
59
59
|
|
@@ -84,7 +84,7 @@ module IsoDoc
|
|
84
84
|
|
85
85
|
def table_parse_tail(node, out)
|
86
86
|
(dl = node.at(ns("./dl"))) && parse(dl, out)
|
87
|
-
node.xpath(ns("./source")).each { |n| parse(n, out) }
|
87
|
+
node.xpath(ns("./fmt-source")).each { |n| parse(n, out) }
|
88
88
|
node.xpath(ns("./note")).each { |n| parse(n, out) }
|
89
89
|
node.xpath(ns("./fmt-footnote-container/fmt-fn-body"))
|
90
90
|
.each { |n| parse(n, out) }
|
@@ -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
|
-
|
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)
|
@@ -151,7 +153,8 @@ module IsoDoc
|
|
151
153
|
when "fn" then footnote_parse(node, out)
|
152
154
|
when "p" then para_parse(node, out)
|
153
155
|
when "quote" then quote_parse(node, out)
|
154
|
-
when "source" then
|
156
|
+
when "source" then semx_source_parse(node, out)
|
157
|
+
when "fmt-source" then source_parse(node, out)
|
155
158
|
when "tr" then tr_parse(node, out)
|
156
159
|
when "note" then note_parse(node, out)
|
157
160
|
when "review" then review_note_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
|
-
|
81
|
-
|
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
|
-
|
93
|
-
|
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)
|