isodoc 2.1.1 → 2.1.3
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/isodoc.gemspec +4 -1
- data/lib/isodoc/base_style/blocks.scss +7 -0
- data/lib/isodoc/class_utils.rb +16 -0
- data/lib/isodoc/function/inline.rb +2 -0
- data/lib/isodoc/function/lists.rb +24 -9
- data/lib/isodoc/function/to_word_html.rb +1 -0
- data/lib/isodoc/function/utils.rb +21 -7
- data/lib/isodoc/gem_tasks.rb +19 -10
- data/lib/isodoc/i18n.rb +19 -0
- data/lib/isodoc/metadata.rb +2 -2
- data/lib/isodoc/presentation_function/block.rb +7 -3
- data/lib/isodoc/presentation_function/image.rb +1 -1
- data/lib/isodoc/presentation_function/inline.rb +11 -12
- data/lib/isodoc/presentation_function/section.rb +1 -1
- data/lib/isodoc/presentation_function/xrefs.rb +23 -9
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +6 -3
- data/lib/isodoc/word_function/inline.rb +7 -2
- data/lib/isodoc/xref/xref_gen.rb +6 -6
- data/lib/isodoc/xref.rb +1 -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-ru.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- metadata +3 -50
- data/.github/workflows/rake.yml +0 -15
- data/.github/workflows/release.yml +0 -24
- data/.hound.yml +0 -5
- data/.oss-guides.rubocop.yml +0 -1077
- data/.rubocop.yml +0 -10
- data/Rakefile +0 -8
- data/bin/rspec +0 -17
- data/spec/assets/header.html +0 -7
- data/spec/assets/html.scss +0 -20
- data/spec/assets/html_override.css +0 -1
- data/spec/assets/htmlcover.html +0 -4
- data/spec/assets/htmlintro.html +0 -5
- data/spec/assets/i18n.yaml +0 -41
- data/spec/assets/iso.xml +0 -8
- data/spec/assets/odf.emf +0 -0
- data/spec/assets/odf.svg +0 -1
- data/spec/assets/odf1.svg +0 -4
- data/spec/assets/outputtest/a.xml +0 -66
- data/spec/assets/outputtest/iso.international-standard.xsl +0 -3011
- data/spec/assets/rice_image1 +0 -0
- data/spec/assets/rice_image1.png +0 -0
- data/spec/assets/scripts.html +0 -3
- data/spec/assets/scripts_override.html +0 -3
- data/spec/assets/std.css +0 -2
- data/spec/assets/word.css +0 -2
- data/spec/assets/word_override.css +0 -1
- data/spec/assets/wordcover.html +0 -3
- data/spec/assets/wordintro.html +0 -4
- data/spec/isodoc/blocks_spec.rb +0 -2934
- data/spec/isodoc/cleanup_spec.rb +0 -1056
- data/spec/isodoc/footnotes_spec.rb +0 -264
- data/spec/isodoc/form_spec.rb +0 -160
- data/spec/isodoc/i18n_spec.rb +0 -1201
- data/spec/isodoc/inline_spec.rb +0 -2301
- data/spec/isodoc/lists_spec.rb +0 -469
- data/spec/isodoc/metadata_spec.rb +0 -401
- data/spec/isodoc/postproc_spec.rb +0 -2938
- data/spec/isodoc/presentation_xml_spec.rb +0 -1476
- data/spec/isodoc/ref_spec.rb +0 -955
- data/spec/isodoc/section_spec.rb +0 -2123
- data/spec/isodoc/table_spec.rb +0 -588
- data/spec/isodoc/terms_spec.rb +0 -712
- data/spec/isodoc/utils_spec.rb +0 -57
- data/spec/isodoc/xref_numbering_spec.rb +0 -378
- data/spec/isodoc/xref_spec.rb +0 -1837
- data/spec/isodoc/xslfo_convert_spec.rb +0 -103
- data/spec/spec_helper.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bf48bda8bc7d17d20a766f93c30bcf9f6e7e597497f8663f2c96ff292ada4f5
|
4
|
+
data.tar.gz: 7efd7f5c3aff9ee37fc631eecd1a564213ab56f92780807d1dff2b17e05c402b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 449d645dc7a4caaf2cd778dedfa4bb995344c3c83b076abbe4ea971b32d6fc9515ee7ae1140d76dfbc5f2c01220513979ea239c095fc2037b84263996a728e4f
|
7
|
+
data.tar.gz: 2031af0175ba1ba995fe3cca887180fa0e0d097dcfd6e2afb51eb7dc60ad8934bfbf4fc17dd9f91f1f2fba8e63e46efd8cee7a2fb2e9693d3f3f804ef432f662
|
data/isodoc.gemspec
CHANGED
@@ -24,7 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.bindir = "bin"
|
26
26
|
spec.require_paths = ["lib"]
|
27
|
-
spec.files = `git ls-files`.split("\
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
f.match(%r{^(test|spec|features|.github)/}) \
|
29
|
+
|| f.match(%r{\.[a-zA-Z0-9_-]+\.yml|Rakefile|bin/rspec})
|
30
|
+
end
|
28
31
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
29
32
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
30
33
|
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -62,5 +62,21 @@ module IsoDoc
|
|
62
62
|
end
|
63
63
|
xml.root.children.to_xml
|
64
64
|
end
|
65
|
+
|
66
|
+
def nearest_block_parent(node)
|
67
|
+
until %w(p title td th name formula li dt dd sourcecode pre quote
|
68
|
+
note example)
|
69
|
+
.include?(node.name)
|
70
|
+
node = node.parent
|
71
|
+
end
|
72
|
+
node
|
73
|
+
end
|
74
|
+
|
75
|
+
# node is at the start of sentence in a Metanorma XML context
|
76
|
+
def start_of_sentence(node)
|
77
|
+
prec = nearest_block_parent(node).xpath("./descendant-or-self::text()") &
|
78
|
+
node.xpath("./preceding::text()")
|
79
|
+
prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map(&:text).join)
|
80
|
+
end
|
65
81
|
end
|
66
82
|
end
|
@@ -1,13 +1,21 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module Function
|
3
3
|
module Lists
|
4
|
+
def list_title_parse(node, out)
|
5
|
+
name = node.at(ns("./name")) or return
|
6
|
+
out.p **{ class: "ListTitle" } do |p|
|
7
|
+
name&.children&.each { |n| parse(n, p) }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
4
11
|
def ul_attrs(node)
|
5
12
|
{ id: node["id"], style: keep_style(node) }
|
6
13
|
end
|
7
14
|
|
8
15
|
def ul_parse(node, out)
|
16
|
+
list_title_parse(node, out)
|
9
17
|
out.ul **attr_code(ul_attrs(node)) do |ul|
|
10
|
-
node.children.each { |n| parse(n, ul) }
|
18
|
+
node.children.each { |n| n.name == "name" or parse(n, ul) }
|
11
19
|
end
|
12
20
|
end
|
13
21
|
|
@@ -44,8 +52,9 @@ module IsoDoc
|
|
44
52
|
end
|
45
53
|
|
46
54
|
def ol_parse(node, out)
|
55
|
+
list_title_parse(node, out)
|
47
56
|
out.ol **attr_code(ol_attrs(node)) do |ol|
|
48
|
-
node.children.each { |n| parse(n, ol) }
|
57
|
+
node.children.each { |n| n.name == "name" or parse(n, ol) }
|
49
58
|
end
|
50
59
|
end
|
51
60
|
|
@@ -82,17 +91,23 @@ module IsoDoc
|
|
82
91
|
end
|
83
92
|
|
84
93
|
def dl_parse(node, out)
|
94
|
+
list_title_parse(node, out)
|
85
95
|
out.dl **dl_attrs(node) do |v|
|
86
96
|
node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
|
87
|
-
v
|
88
|
-
dt_parse(dt, term)
|
89
|
-
end
|
90
|
-
v.dd **attr_code(id: dd["id"]) do |listitem|
|
91
|
-
dd.children.each { |n| parse(n, listitem) }
|
92
|
-
end
|
97
|
+
dl_parse1(v, dt, dd)
|
93
98
|
end
|
94
99
|
end
|
95
|
-
node.elements.reject { |n| dt_dd?
|
100
|
+
node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
|
101
|
+
.each { |n| parse(n, out) }
|
102
|
+
end
|
103
|
+
|
104
|
+
def dl_parse1(dlist, dterm, ddef)
|
105
|
+
dlist.dt **attr_code(id: dterm["id"]) do |term|
|
106
|
+
dt_parse(dterm, term)
|
107
|
+
end
|
108
|
+
dlist.dd **attr_code(id: ddef["id"]) do |listitem|
|
109
|
+
ddef.children.each { |n| parse(n, listitem) }
|
110
|
+
end
|
96
111
|
end
|
97
112
|
end
|
98
113
|
end
|
@@ -11,6 +11,10 @@ module IsoDoc
|
|
11
11
|
self.class.ns(xpath)
|
12
12
|
end
|
13
13
|
|
14
|
+
def start_of_sentence(node)
|
15
|
+
self.class.start_of_sentence(node)
|
16
|
+
end
|
17
|
+
|
14
18
|
def insert_tab(out, count)
|
15
19
|
tab = %w(Hans Hant).include?(@script) ? " " : "  "
|
16
20
|
[1..count].each { out << tab }
|
@@ -58,24 +62,30 @@ module IsoDoc
|
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
|
-
def
|
62
|
-
|
63
|
-
/<!DOCTYPE /.match(xml) || (xml = DOCTYPE_HDR + xml)
|
65
|
+
def numeric_escapes(xml)
|
66
|
+
c = HTMLEntities.new
|
64
67
|
xml.split(/(&[^ \r\n\t#;]+;)/).map do |t|
|
65
68
|
if /^(&[^ \t\r\n#;]+;)/.match?(t)
|
66
|
-
|
69
|
+
c.encode(c.decode(t), :hexadecimal)
|
67
70
|
else t
|
68
71
|
end
|
69
72
|
end.join
|
70
73
|
end
|
71
74
|
|
75
|
+
def to_xhtml_prep(xml)
|
76
|
+
xml.gsub!(/<\?xml[^>]*>/, "")
|
77
|
+
/<!DOCTYPE /.match(xml) || (xml = DOCTYPE_HDR + xml)
|
78
|
+
numeric_escapes(xml)
|
79
|
+
end
|
80
|
+
|
72
81
|
def to_xhtml_fragment(xml)
|
73
82
|
doc = ::Nokogiri::XML.parse(NOKOHEAD)
|
74
83
|
doc.fragment(xml)
|
75
84
|
end
|
76
85
|
|
77
86
|
def from_xhtml(xml)
|
78
|
-
xml.to_xml
|
87
|
+
numeric_escapes(xml.to_xml
|
88
|
+
.sub(%r{ xmlns="http://www.w3.org/1999/xhtml"}, ""))
|
79
89
|
end
|
80
90
|
|
81
91
|
CLAUSE_ANCESTOR =
|
@@ -100,8 +110,12 @@ module IsoDoc
|
|
100
110
|
"local-name() = 'figure' or local-name() = 'formula' or "\
|
101
111
|
"local-name() = 'table' or local-name() = 'example']/@id"
|
102
112
|
|
103
|
-
|
104
|
-
|
113
|
+
# no recursion on references
|
114
|
+
def get_note_container_id(node, type)
|
115
|
+
xpath = NOTE_CONTAINER_ANCESTOR.dup
|
116
|
+
%w(figure table example).include?(type) and
|
117
|
+
xpath.sub!(%r[ or local-name\(\) = '#{type}'], "")
|
118
|
+
container = node.xpath(xpath)
|
105
119
|
container&.last&.text || nil
|
106
120
|
end
|
107
121
|
|
data/lib/isodoc/gem_tasks.rb
CHANGED
@@ -8,14 +8,20 @@ module IsoDoc
|
|
8
8
|
module GemTasks
|
9
9
|
extend Rake::DSL if defined? Rake::DSL
|
10
10
|
|
11
|
+
@@css_list = []
|
12
|
+
|
11
13
|
module_function
|
12
14
|
|
15
|
+
def self.css_list
|
16
|
+
@@css_list
|
17
|
+
end
|
18
|
+
|
13
19
|
def install
|
14
20
|
rule ".css" => [proc { |tn| tn.sub(/\.css$/, ".scss") }] do |current_task|
|
15
21
|
puts(current_task)
|
16
22
|
compile_scss_task(current_task)
|
17
23
|
rescue StandardError => e
|
18
|
-
|
24
|
+
notify_broken_compilation(e, current_task)
|
19
25
|
end
|
20
26
|
|
21
27
|
scss_files = Rake::FileList["lib/**/*.scss"]
|
@@ -40,25 +46,27 @@ module IsoDoc
|
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
|
-
def
|
49
|
+
def interactive?
|
50
|
+
ENV["CI"] == nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def notify_broken_compilation(error, current_task)
|
44
54
|
puts("Cannot compile #{current_task} because of #{error.message}")
|
55
|
+
return unless interactive?
|
56
|
+
|
45
57
|
puts("continue anyway[y|n]?")
|
46
|
-
answer =
|
47
|
-
|
48
|
-
puts("Cannot compile #{current_task} because of #{error.message}")
|
49
|
-
else
|
50
|
-
exit(0)
|
51
|
-
end
|
58
|
+
answer = $stdin.gets.strip
|
59
|
+
exit(0) unless %w[y yes].include?(answer.strip.downcase)
|
52
60
|
end
|
53
61
|
|
54
62
|
def git_cache_compiled_files
|
55
|
-
|
63
|
+
@@css_list.each do |css_file|
|
56
64
|
sh "git add #{css_file}"
|
57
65
|
end
|
58
66
|
end
|
59
67
|
|
60
68
|
def git_rm_compiled_files
|
61
|
-
|
69
|
+
@@css_list.each do |css_file|
|
62
70
|
sh "git rm --cached #{css_file}"
|
63
71
|
end
|
64
72
|
end
|
@@ -129,6 +137,7 @@ module IsoDoc
|
|
129
137
|
File.open(compiled_path, "w:UTF-8") do |f|
|
130
138
|
f.write(content)
|
131
139
|
end
|
140
|
+
@@css_list << compiled_path
|
132
141
|
CLEAN << compiled_path
|
133
142
|
end
|
134
143
|
end
|
data/lib/isodoc/i18n.rb
CHANGED
@@ -23,3 +23,22 @@ module IsoDoc
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
class ::Hash
|
28
|
+
def deep_merge(second)
|
29
|
+
merger = proc { |_, v1, v2|
|
30
|
+
if Hash === v1 && Hash === v2
|
31
|
+
v1.merge(v2, &merger)
|
32
|
+
elsif Array === v1 && Array === v2
|
33
|
+
v1 | v2
|
34
|
+
elsif [:undefined, nil,
|
35
|
+
:nil].include?(v2)
|
36
|
+
v1
|
37
|
+
else
|
38
|
+
v2
|
39
|
+
end
|
40
|
+
}
|
41
|
+
merge(second.to_h, &merger)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -8,6 +8,10 @@ module IsoDoc
|
|
8
8
|
text.capitalize
|
9
9
|
end
|
10
10
|
|
11
|
+
def block_delim
|
12
|
+
" — "
|
13
|
+
end
|
14
|
+
|
11
15
|
def prefix_name(node, delim, number, elem)
|
12
16
|
return if number.nil? || number.empty?
|
13
17
|
|
@@ -31,7 +35,7 @@ module IsoDoc
|
|
31
35
|
return if labelled_ancestor(elem)
|
32
36
|
|
33
37
|
lbl = @xrefs.anchor(elem["id"], :label, false) or return
|
34
|
-
prefix_name(elem,
|
38
|
+
prefix_name(elem, block_delim,
|
35
39
|
l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
36
40
|
end
|
37
41
|
|
@@ -60,7 +64,7 @@ module IsoDoc
|
|
60
64
|
else
|
61
65
|
l10n("#{@i18n.example} #{n[:label]}")
|
62
66
|
end
|
63
|
-
prefix_name(elem,
|
67
|
+
prefix_name(elem, block_delim, lbl, "name")
|
64
68
|
end
|
65
69
|
|
66
70
|
def note(docxml)
|
@@ -130,7 +134,7 @@ module IsoDoc
|
|
130
134
|
return if elem["unnumbered"] && !elem.at(ns("./name"))
|
131
135
|
|
132
136
|
n = @xrefs.anchor(elem["id"], :label, false)
|
133
|
-
prefix_name(elem,
|
137
|
+
prefix_name(elem, block_delim, l10n("#{lower2cap @i18n.table} #{n}"),
|
134
138
|
"name")
|
135
139
|
end
|
136
140
|
|
@@ -32,7 +32,7 @@ module IsoDoc
|
|
32
32
|
return if elem.at(ns("./figure")) && !elem.at(ns("./name"))
|
33
33
|
|
34
34
|
lbl = @xrefs.anchor(elem["id"], :label, false) or return
|
35
|
-
prefix_name(elem,
|
35
|
+
prefix_name(elem, block_delim,
|
36
36
|
l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
37
37
|
end
|
38
38
|
|
@@ -3,14 +3,6 @@ require_relative "xrefs"
|
|
3
3
|
|
4
4
|
module IsoDoc
|
5
5
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
6
|
-
def nearest_block_parent(node)
|
7
|
-
until %w(p title td th name formula li dt dd sourcecode pre)
|
8
|
-
.include?(node.name)
|
9
|
-
node = node.parent
|
10
|
-
end
|
11
|
-
node
|
12
|
-
end
|
13
|
-
|
14
6
|
def non_locality_elems(node)
|
15
7
|
node.children.reject do |c|
|
16
8
|
%w{locality localityStack location}.include? c.name
|
@@ -179,12 +171,13 @@ module IsoDoc
|
|
179
171
|
def eref_locality_populate(type, node)
|
180
172
|
return "" if node["droploc"] == "true"
|
181
173
|
|
182
|
-
loc =
|
183
|
-
|
174
|
+
loc = type.sub(/^locality:/, "")
|
175
|
+
ret = @i18n.locality[loc] || loc
|
176
|
+
ret = case node["case"]
|
184
177
|
when "lowercase" then loc.downcase
|
185
|
-
else Metanorma::Utils.strict_capitalize_first(
|
178
|
+
else Metanorma::Utils.strict_capitalize_first(ret)
|
186
179
|
end
|
187
|
-
" #{
|
180
|
+
" #{ret}"
|
188
181
|
end
|
189
182
|
|
190
183
|
def xref(docxml)
|
@@ -226,6 +219,12 @@ module IsoDoc
|
|
226
219
|
end
|
227
220
|
end
|
228
221
|
|
222
|
+
def identifier(docxml)
|
223
|
+
docxml.xpath(ns("//identifier")).each do |n|
|
224
|
+
n.name = "tt"
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
229
228
|
private
|
230
229
|
|
231
230
|
def found_matching_variant_sibling(node)
|
@@ -177,7 +177,7 @@ module IsoDoc
|
|
177
177
|
|
178
178
|
def toc(docxml)
|
179
179
|
docxml.xpath(ns("//toc//xref[text()]")).each do |x|
|
180
|
-
lbl = @xrefs.
|
180
|
+
lbl = @xrefs.anchor(x["target"], :label) or next
|
181
181
|
x.children.first.previous = "#{lbl}<tab/>"
|
182
182
|
end
|
183
183
|
end
|
@@ -26,24 +26,39 @@ module IsoDoc
|
|
26
26
|
def anchor_linkend1(node)
|
27
27
|
linkend = @xrefs.anchor(node["target"], :xref)
|
28
28
|
container = @xrefs.anchor(node["target"], :container, false)
|
29
|
-
(container
|
30
|
-
@xrefs.get[node["target"]]) and
|
29
|
+
prefix_container?(container, node) and
|
31
30
|
linkend = prefix_container(container, linkend, node["target"])
|
32
31
|
capitalise_xref(node, linkend, anchor_value(node["target"]))
|
33
32
|
end
|
34
33
|
|
34
|
+
def prefix_container?(container, node)
|
35
|
+
type = @xrefs.anchor(node["target"], :type)
|
36
|
+
container &&
|
37
|
+
get_note_container_id(node, type) != container &&
|
38
|
+
@xrefs.get[node["target"]]
|
39
|
+
end
|
40
|
+
|
35
41
|
def combine_xref_locations(node)
|
36
42
|
locs = gather_xref_locations(node)
|
37
43
|
linkend = if can_conflate_xref_rendering?(locs)
|
38
|
-
|
39
|
-
l10n("#{locs.first[:elem]} #{combine_conn(out)}")
|
44
|
+
combine_conflated_xref_locations(locs)
|
40
45
|
else
|
41
|
-
out = locs.each { |l| l[:target] =
|
46
|
+
out = locs.each { |l| l[:target] = anchor_linkend1(l[:node]) }
|
42
47
|
l10n(combine_conn(out))
|
43
48
|
end
|
44
49
|
capitalise_xref(node, linkend, anchor_value(node["target"]))
|
45
50
|
end
|
46
51
|
|
52
|
+
def combine_conflated_xref_locations(locs)
|
53
|
+
out = locs.each { |l| l[:target] = anchor_value(l[:target]) }
|
54
|
+
ret = l10n("#{locs.first[:elem]} #{combine_conn(out)}")
|
55
|
+
container = @xrefs.anchor(locs.first[:node]["target"], :container,
|
56
|
+
false)
|
57
|
+
prefix_container?(container, locs.first[:node]) and
|
58
|
+
ret = prefix_container(container, ret, locs.first[:node]["target"])
|
59
|
+
ret
|
60
|
+
end
|
61
|
+
|
47
62
|
def gather_xref_locations(node)
|
48
63
|
node.xpath(ns("./location")).each_with_object([]) do |l, m|
|
49
64
|
type = @xrefs.anchor(l["target"], :type)
|
@@ -74,7 +89,8 @@ module IsoDoc
|
|
74
89
|
end
|
75
90
|
|
76
91
|
def can_conflate_xref_rendering?(locs)
|
77
|
-
|
92
|
+
(locs.all? { |l| l[:container].nil? } ||
|
93
|
+
locs.all? { |l| l[:container] == locs.first[:container] }) &&
|
78
94
|
locs.all? { |l| l[:type] == locs[0][:type] }
|
79
95
|
end
|
80
96
|
|
@@ -89,9 +105,7 @@ module IsoDoc
|
|
89
105
|
end
|
90
106
|
|
91
107
|
def capitalise_xref1(node, linkend)
|
92
|
-
|
93
|
-
node.xpath("./preceding::text()")
|
94
|
-
if prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map(&:text).join)
|
108
|
+
if start_of_sentence(node)
|
95
109
|
Common::case_with_markup(linkend, "capital", @script)
|
96
110
|
else linkend
|
97
111
|
end
|
data/lib/isodoc/version.rb
CHANGED
@@ -92,8 +92,10 @@ module IsoDoc
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def dl_parse_table(node, out)
|
95
|
+
list_title_parse(node, out)
|
95
96
|
out.table **{ class: "dl" } do |v|
|
96
|
-
node.elements.select { |n| dt_dd?
|
97
|
+
node.elements.select { |n| dt_dd?(n) }
|
98
|
+
.each_slice(2) do |dt, dd|
|
97
99
|
dl_parse_table1(v, dt, dd)
|
98
100
|
end
|
99
101
|
dl_parse_notes(node, v)
|
@@ -112,11 +114,12 @@ module IsoDoc
|
|
112
114
|
end
|
113
115
|
|
114
116
|
def dl_parse_notes(node, out)
|
115
|
-
|
117
|
+
remainder = node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
|
118
|
+
return if remainder.empty?
|
116
119
|
|
117
120
|
out.tr do |tr|
|
118
121
|
tr.td **{ colspan: 2 } do |td|
|
119
|
-
|
122
|
+
remainder.each { |n| parse(n, td) }
|
120
123
|
end
|
121
124
|
end
|
122
125
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module WordFunction
|
3
3
|
module Body
|
4
|
-
def section_break(body)
|
4
|
+
def section_break(body, continuous: false)
|
5
5
|
body.p do |p|
|
6
|
-
|
6
|
+
if continuous
|
7
|
+
p.br **{ clear: "all", style: "page-break-before:auto;"\
|
8
|
+
"mso-break-type:section-break" }
|
9
|
+
else
|
10
|
+
p.br **{ clear: "all", class: "section" }
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
9
14
|
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -43,7 +43,7 @@ module IsoDoc
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def termnote_anchor_names(docxml)
|
46
|
-
docxml.xpath(ns("
|
46
|
+
docxml.xpath(ns("//*[termnote]")).each do |t|
|
47
47
|
c = Counter.new
|
48
48
|
t.xpath(ns("./termnote")).reject { |n| blank?(n["id"]) }.each do |n|
|
49
49
|
c.increment(n)
|
@@ -57,7 +57,7 @@ module IsoDoc
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def termexample_anchor_names(docxml)
|
60
|
-
docxml.xpath(ns("
|
60
|
+
docxml.xpath(ns("//*[termexample]")).each do |t|
|
61
61
|
examples = t.xpath(ns("./termexample"))
|
62
62
|
c = Counter.new
|
63
63
|
examples.reject { |n| blank?(n["id"]) }.each do |n|
|
@@ -148,12 +148,12 @@ module IsoDoc
|
|
148
148
|
c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
|
149
149
|
list.xpath(ns("./li")).each do |li|
|
150
150
|
label = c.increment(li).listlabel(list, depth)
|
151
|
-
label = "#{prev_label}
|
151
|
+
label = "#{prev_label}) #{label}" unless prev_label.empty?
|
152
152
|
label = "#{list_anchor[:xref]} #{label}" if refer_list
|
153
153
|
li["id"] and @anchors[li["id"]] =
|
154
|
-
{ xref: "#{label})", type: "listitem",
|
155
|
-
container: list_anchor[:container] }
|
156
|
-
li.xpath(ns("
|
154
|
+
{ xref: "#{label})", type: "listitem", refer_list:
|
155
|
+
refer_list, container: list_anchor[:container] }
|
156
|
+
(li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
|
157
157
|
list_item_anchor_names(ol, list_anchor, depth + 1, label, false)
|
158
158
|
end
|
159
159
|
end
|
data/lib/isodoc/xref.rb
CHANGED
@@ -52,7 +52,7 @@ module IsoDoc
|
|
52
52
|
|
53
53
|
# extract names for all anchors, xref and label
|
54
54
|
def parse(docxml)
|
55
|
-
amend_preprocess(docxml) if
|
55
|
+
amend_preprocess(docxml) if @parse_settings.empty?
|
56
56
|
initial_anchor_names(docxml)
|
57
57
|
back_anchor_names(docxml)
|
58
58
|
# preempt clause notes with all other types of note (ISO default)
|