isodoc 2.10.0 → 3.0.0

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/isodoc.gemspec +9 -4
  4. data/lib/isodoc/base_style/all.css +96 -0
  5. data/lib/isodoc/base_style/reset.css +96 -0
  6. data/lib/isodoc/base_style/reset.scss +75 -0
  7. data/lib/isodoc/base_style/scripts.html +45 -14
  8. data/lib/isodoc/class_utils.rb +4 -2
  9. data/lib/isodoc/convert.rb +0 -21
  10. data/lib/isodoc/css.rb +2 -4
  11. data/lib/isodoc/function/blocks.rb +37 -52
  12. data/lib/isodoc/function/blocks_example_note.rb +75 -29
  13. data/lib/isodoc/function/cleanup.rb +9 -44
  14. data/lib/isodoc/function/inline.rb +67 -13
  15. data/lib/isodoc/function/lists.rb +20 -14
  16. data/lib/isodoc/function/references.rb +9 -126
  17. data/lib/isodoc/function/reqt.rb +4 -3
  18. data/lib/isodoc/function/section.rb +30 -35
  19. data/lib/isodoc/function/section_titles.rb +22 -11
  20. data/lib/isodoc/function/table.rb +3 -3
  21. data/lib/isodoc/function/terms.rb +49 -26
  22. data/lib/isodoc/function/to_word_html.rb +46 -16
  23. data/lib/isodoc/function/utils.rb +11 -12
  24. data/lib/isodoc/gem_tasks.rb +1 -1
  25. data/lib/isodoc/html_function/footnotes.rb +2 -1
  26. data/lib/isodoc/html_function/html.rb +5 -7
  27. data/lib/isodoc/html_function/postprocess.rb +25 -6
  28. data/lib/isodoc/html_function/postprocess_cover.rb +13 -7
  29. data/lib/isodoc/html_function/postprocess_footnotes.rb +52 -47
  30. data/lib/isodoc/init.rb +31 -0
  31. data/lib/isodoc/metadata.rb +20 -13
  32. data/lib/isodoc/metadata_contributor.rb +5 -10
  33. data/lib/isodoc/metadata_date.rb +1 -1
  34. data/lib/isodoc/presentation_function/autonum.rb +153 -0
  35. data/lib/isodoc/presentation_function/bibdata.rb +4 -5
  36. data/lib/isodoc/presentation_function/block.rb +107 -40
  37. data/lib/isodoc/presentation_function/concepts.rb +184 -19
  38. data/lib/isodoc/presentation_function/docid.rb +78 -0
  39. data/lib/isodoc/presentation_function/erefs.rb +55 -31
  40. data/lib/isodoc/presentation_function/image.rb +64 -19
  41. data/lib/isodoc/presentation_function/index.rb +180 -0
  42. data/lib/isodoc/presentation_function/inline.rb +47 -16
  43. data/lib/isodoc/presentation_function/math.rb +128 -71
  44. data/lib/isodoc/presentation_function/metadata.rb +29 -66
  45. data/lib/isodoc/presentation_function/refs.rb +75 -28
  46. data/lib/isodoc/presentation_function/reqt.rb +7 -4
  47. data/lib/isodoc/presentation_function/section.rb +51 -129
  48. data/lib/isodoc/presentation_function/sourcecode.rb +52 -19
  49. data/lib/isodoc/presentation_function/terms.rb +107 -118
  50. data/lib/isodoc/presentation_function/title.rb +107 -0
  51. data/lib/isodoc/presentation_function/xrefs.rb +37 -17
  52. data/lib/isodoc/presentation_xml_convert.rb +24 -10
  53. data/lib/isodoc/version.rb +1 -1
  54. data/lib/isodoc/word_function/body.rb +9 -37
  55. data/lib/isodoc/word_function/comments.rb +0 -1
  56. data/lib/isodoc/word_function/footnotes.rb +1 -1
  57. data/lib/isodoc/word_function/lists.rb +13 -9
  58. data/lib/isodoc/word_function/postprocess.rb +6 -0
  59. data/lib/isodoc/word_function/postprocess_cover.rb +6 -4
  60. data/lib/isodoc/word_function/postprocess_table.rb +1 -1
  61. data/lib/isodoc/word_function/postprocess_toc.rb +10 -6
  62. data/lib/isodoc/word_function/table.rb +2 -2
  63. data/lib/isodoc/xref/clause_order.rb +41 -0
  64. data/lib/isodoc/xref/xref_anchor.rb +31 -16
  65. data/lib/isodoc/xref/xref_counter.rb +18 -3
  66. data/lib/isodoc/xref/xref_counter_types.rb +14 -0
  67. data/lib/isodoc/xref/xref_gen.rb +61 -37
  68. data/lib/isodoc/xref/xref_gen_seq.rb +148 -81
  69. data/lib/isodoc/xref/xref_sect_gen.rb +84 -88
  70. data/lib/isodoc/xref/xref_util.rb +53 -4
  71. data/lib/isodoc/xref.rb +29 -10
  72. data/lib/isodoc/xslfo_convert.rb +14 -9
  73. data/lib/isodoc-yaml/i18n-ar.yaml +17 -13
  74. data/lib/isodoc-yaml/i18n-de.yaml +17 -13
  75. data/lib/isodoc-yaml/i18n-en.yaml +18 -17
  76. data/lib/isodoc-yaml/i18n-es.yaml +17 -13
  77. data/lib/isodoc-yaml/i18n-fr.yaml +17 -13
  78. data/lib/isodoc-yaml/i18n-ja.yaml +56 -52
  79. data/lib/isodoc-yaml/i18n-ru.yaml +17 -16
  80. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +17 -13
  81. data/lib/nokogiri/xml/node.rb +14 -0
  82. data/lib/relaton/render-isodoc/config.yml +1 -1
  83. metadata +90 -13
@@ -1,103 +1,25 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
- def designation(docxml)
4
- docxml.xpath(ns("//term")).each { |t| merge_second_preferred(t) }
5
- docxml.xpath(ns("//preferred | //admitted | //deprecates"))
6
- .each { |p| designation1(p) }
7
- docxml.xpath(ns("//deprecates")).each { |d| deprecates(d) }
8
- docxml.xpath(ns("//admitted")).each { |d| admits(d) }
9
- end
10
-
11
- def deprecates(elem)
12
- elem.children.first.previous = @i18n.l10n("#{@i18n.deprecated}: ")
13
- end
14
-
15
- def admits(elem); end
16
-
17
- def merge_second_preferred(term)
18
- pref = nil
19
- term.xpath(ns("./preferred[expression/name]")).each_with_index do |p, i|
20
- (i.zero? and pref = p) or merge_second_preferred1(pref, p)
21
- end
22
- end
23
-
24
- def merge_second_preferred1(pref, second)
25
- merge_preferred_eligible?(pref, second) or return
26
- n1 = pref.at(ns("./expression/name"))
27
- n2 = second.remove.at(ns("./expression/name"))
28
- n1.children = l10n("#{to_xml(n1.children)}; #{Common::to_xml(n2.children)}")
29
- end
30
-
31
- def merge_preferred_eligible?(first, second)
32
- firstex = first.at(ns("./expression")) || {}
33
- secondex = second.at(ns("./expression")) || {}
34
- first["geographic-area"] == second["geographic-area"] &&
35
- firstex["language"] == secondex["language"] &&
36
- !first.at(ns("./pronunciation | ./grammar")) &&
37
- !second.at(ns("./pronunciation | ./grammar"))
38
- end
39
-
40
- def designation1(desgn)
41
- s = desgn.at(ns("./termsource"))
42
- name = desgn.at(ns("./expression/name | ./letter-symbol/name | " \
43
- "./graphical-symbol")) or return
44
- designation_annotate(desgn, name)
45
- s and desgn.next = s
46
- end
47
-
48
- def designation_annotate(desgn, name)
49
- designation_boldface(desgn)
50
- designation_field(desgn, name)
51
- g = desgn.at(ns("./expression/grammar")) and
52
- name << ", #{designation_grammar(g).join(', ')}"
53
- designation_localization(desgn, name)
54
- designation_pronunciation(desgn, name)
55
- designation_bookmarks(desgn, name)
56
- desgn.children = name.children
57
- end
58
-
59
- def designation_boldface(desgn)
60
- desgn.name == "preferred" or return
61
- name = desgn.at(ns("./expression/name | ./letter-symbol/name")) or return
62
- name.children = "<strong>#{name.children}</strong>"
63
- end
64
-
65
- def designation_field(desgn, name)
66
- f = desgn.xpath(ns("./field-of-application | ./usage-info"))
67
- &.map { |u| to_xml(u.children) }&.join(", ")
68
- f&.empty? and return nil
69
- name << ", &#x3c;#{f}&#x3e;"
70
- end
71
-
72
- def designation_grammar(grammar)
73
- ret = []
74
- grammar.xpath(ns("./gender | ./number")).each do |x|
75
- ret << @i18n.grammar_abbrevs[x.text]
3
+ def termcontainers(docxml)
4
+ docxml.xpath(ns("//term")).each do |t|
5
+ %w(preferred admitted deprecates related definition termsource)
6
+ .each do |w|
7
+ d = t.at(ns("./#{w}[last()]")) and d.after("<fmt-#{w}/>")
8
+ end
76
9
  end
77
- %w(isPreposition isParticiple isAdjective isVerb isAdverb isNoun)
78
- .each do |x|
79
- grammar.at(ns("./#{x}[text() = 'true']")) and
80
- ret << @i18n.grammar_abbrevs[x]
10
+ docxml.xpath(ns("//termsource")).each do |s|
11
+ s["id"] ||= "_#{UUIDTools::UUID.random_create}"
81
12
  end
82
- ret
83
- end
84
-
85
- def designation_localization(desgn, name)
86
- loc = [desgn&.at(ns("./expression/@language"))&.text,
87
- desgn&.at(ns("./expression/@script"))&.text,
88
- desgn&.at(ns("./@geographic-area"))&.text].compact
89
- loc.empty? and return
90
- name << ", #{loc.join(' ')}"
91
13
  end
92
14
 
93
- def designation_pronunciation(desgn, name)
94
- f = desgn.at(ns("./expression/pronunciation")) or return
95
- name << ", /#{to_xml(f.children)}/"
96
- end
97
-
98
- def designation_bookmarks(desgn, name)
99
- desgn.xpath(ns(".//bookmark")).each do |b|
100
- name << b.remove
15
+ def termcleanup(docxml)
16
+ docxml.xpath(ns("//term")).each do |t|
17
+ %w(preferred admitted deprecates related definition termsource)
18
+ .each do |w|
19
+ t.xpath(ns("./#{w}//fmt-name | ./#{w}//fmt-xref-label")).each(&:remove)
20
+ f = t.at(ns(".//fmt-#{w}"))
21
+ f&.children&.empty? and f.remove
22
+ end
101
23
  end
102
24
  end
103
25
 
@@ -109,34 +31,46 @@ module IsoDoc
109
31
  docxml.xpath(ns("//termnote")).each { |f| termnote1(f) }
110
32
  end
111
33
 
34
+ def termnote_delim(_elem)
35
+ l10n(": ")
36
+ end
37
+
112
38
  def termnote1(elem)
113
- lbl = l10n(@xrefs.anchor(elem["id"], :label) || "???")
114
- prefix_name(elem, "", lower2cap(lbl), "name")
39
+ lbl = termnote_label(elem)
40
+ prefix_name(elem, { label: termnote_delim(elem) }, lower2cap(lbl), "name")
41
+ end
42
+
43
+ def termnote_label(elem)
44
+ @xrefs.anchor(elem["id"], :label) || "???"
115
45
  end
116
46
 
117
47
  def termdefinition(docxml)
118
- docxml.xpath(ns("//term[definition]")).each do |f|
119
- termdefinition1(f)
120
- end
48
+ docxml.xpath(ns("//term[definition]")).each { |f| termdefinition1(f) }
121
49
  end
122
50
 
123
51
  def termdefinition1(elem)
124
- unwrap_definition(elem)
125
- multidef(elem) if elem.xpath(ns("./definition")).size > 1
52
+ d = elem.xpath(ns("./definition"))
53
+ d1 = elem.at(ns("./fmt-definition"))
54
+ if d.size > 1 then multidef(elem, d, d1)
55
+ else singledef(elem, d, d1)
56
+ end
57
+ unwrap_definition(elem, d1)
58
+ termdomain(elem, d1)
126
59
  end
127
60
 
128
- def multidef(elem)
129
- d = elem.at(ns("./definition"))
130
- d = d.replace("<ol><li>#{to_xml(d.children)}</li></ol>").first
131
- elem.xpath(ns("./definition")).each do |f|
132
- f = f.replace("<li>#{to_xml(f.children)}</li>").first
133
- d << f
61
+ def multidef(_elem, defn, fmt_defn)
62
+ ret = defn.each_with_object([]) do |f, m|
63
+ m << "<li>#{to_xml(semx_fmt_dup(f))}</li>"
134
64
  end
135
- d.wrap("<definition></definition>")
65
+ fmt_defn << "<ol>#{ret.join("\n")}</ol>"
136
66
  end
137
67
 
138
- def unwrap_definition(elem)
139
- elem.xpath(ns("./definition")).each do |d|
68
+ def singledef(_elem, defn, fmt_defn)
69
+ fmt_defn << semx_fmt_dup(defn.first)
70
+ end
71
+
72
+ def unwrap_definition(_elem, fmt_defn)
73
+ fmt_defn.xpath(ns(".//semx[@element = 'definition']")).each do |d|
140
74
  %w(verbal-definition non-verbal-representation).each do |e|
141
75
  v = d&.at(ns("./#{e}"))
142
76
  v&.replace(v.children)
@@ -144,19 +78,62 @@ module IsoDoc
144
78
  end
145
79
  end
146
80
 
81
+ def termdomain(elem, fmt_defn)
82
+ d = elem.at(ns(".//domain")) or return
83
+ p = fmt_defn.at(ns(".//p")) or return
84
+ d1 = semx_fmt_dup(d)
85
+ p.add_first_child "&lt;#{to_xml(d1)}&gt; "
86
+ end
87
+
147
88
  def termsource(docxml)
148
- docxml.xpath(ns("//termsource")).each { |f| termsource_modification(f) }
149
- docxml.xpath(ns("//termsource")).each { |f| termsource1(f) }
89
+ copy_baselevel_termsource(docxml)
90
+ # TODO should I wrap fmt-definition//termsource in fmt-termsource, in order to preserve termsource attributes?
91
+ docxml.xpath(ns("//fmt-termsource/termsource | //fmt-definition//termsource | //fmt-preferred//termsource | //fmt-admitted//termsource | //fmt-deprecates//termsource"))
92
+ .each do |f|
93
+ termsource_modification(f)
94
+ end
95
+ docxml.xpath(ns("//fmt-preferred//fmt-termsource | //fmt-admitted//fmt-termsource | //fmt-deprecates//fmt-termsource"))
96
+ .each do |f|
97
+ termsource_designation(f)
98
+ end
99
+ docxml.xpath(ns("//fmt-termsource/termsource | //fmt-definition//termsource | //fmt-preferred//termsource | //fmt-admitted//termsource | //fmt-deprecates//termsource"))
100
+ .each do |f|
101
+ f.parent and termsource1(f)
102
+ end
103
+ end
104
+
105
+ def termsource_designation(fmtsource)
106
+ p = fmtsource.previous_element
107
+ p&.name == "p" or return
108
+ p << " "
109
+ p << fmtsource.children
110
+ end
111
+
112
+ def copy_baselevel_termsource(docxml)
113
+ docxml.xpath(ns("//term[termsource]")).each do |x|
114
+ s = x.xpath(ns("./termsource"))
115
+ s1 = x.at(ns("./fmt-termsource"))
116
+ s.each { |ss| s1 << ss.clone }
117
+ strip_duplicate_ids(nil, s, s1)
118
+ %w(status type).each { |a| s[0][a] and s1[a] = s[0][a] }
119
+ end
150
120
  end
151
121
 
152
122
  def termsource1(elem)
123
+ ret = [semx_fmt_dup(elem)]
153
124
  while elem&.next_element&.name == "termsource"
154
- elem << "; #{to_xml(elem.next_element.remove.children)}"
125
+ ret << semx_fmt_dup(elem.next_element.remove)
155
126
  end
156
- elem.children = l10n("[#{@i18n.source}: #{to_xml(elem.children).strip}]")
127
+ s = ret.map { |x| to_xml(x) }.map(&:strip).join("; ")
128
+ termsource_label(elem, s)
129
+ end
130
+
131
+ def termsource_label(elem, sources)
132
+ elem.replace(l10n("[#{@i18n.source}: #{sources}]"))
157
133
  end
158
134
 
159
135
  def termsource_modification(elem)
136
+ elem.xpath(".//text()[normalize-space() = '']").each(&:remove)
160
137
  origin = elem.at(ns("./origin"))
161
138
  s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
162
139
  termsource_add_modification_text(elem.at(ns("./modification")))
@@ -164,10 +141,13 @@ module IsoDoc
164
141
 
165
142
  def termsource_add_modification_text(mod)
166
143
  mod or return
167
- mod.text.strip.empty? or mod.previous = " &#x2014; "
168
- mod.elements.size == 1 and
169
- mod.elements[0].replace(mod.elements[0].children)
170
- mod.replace(mod.children)
144
+ if mod.text.strip.empty?
145
+ mod.remove
146
+ return
147
+ end
148
+ mod.previous = " &#x2014; "
149
+ mod.elements.size == 1 and mod.children = to_xml(mod.elements[0].children)
150
+ mod.replace(semx_fmt_dup(mod))
171
151
  end
172
152
 
173
153
  def termsource_status(status)
@@ -176,5 +156,14 @@ module IsoDoc
176
156
  when "adapted" then @i18n.adapted
177
157
  end
178
158
  end
159
+
160
+ def term(docxml)
161
+ docxml.xpath(ns("//term")).each { |f| term1(f) }
162
+ end
163
+
164
+ def term1(elem)
165
+ lbl = @xrefs.anchor(elem["id"], :label) or return
166
+ prefix_name(elem, {}, "#{lbl}#{clausedelim}", "name")
167
+ end
179
168
  end
180
169
  end
@@ -0,0 +1,107 @@
1
+ require_relative "refs"
2
+
3
+ module IsoDoc
4
+ class PresentationXMLConvert < ::IsoDoc::Convert
5
+ def middle_title(docxml)
6
+ s = docxml.at(ns("//sections")) or return
7
+ t = @meta.get[:doctitle]
8
+ t.nil? || t.empty? and return
9
+ s.add_first_child "<p class='zzSTDTitle1'>#{t}</p>"
10
+ end
11
+
12
+ def missing_title(docxml)
13
+ docxml.xpath(ns("//definitions[not(./title)]")).each do |d|
14
+ # should only be happening for subclauses
15
+ d.add_first_child "<title>#{@i18n.symbols}</title>"
16
+ end
17
+ docxml.xpath(ns("//foreword[not(./title)]")).each do |d|
18
+ d.add_first_child "<title>#{@i18n.foreword}</title>"
19
+ end
20
+ end
21
+
22
+ def floattitle(docxml)
23
+ docxml.xpath(ns(".//floating-title")).each { |f| floattitle1(f) }
24
+ end
25
+
26
+ # TODO not currently doing anything with the @depth attribute of floating-title
27
+ def floattitle1(elem)
28
+ elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
29
+ p = elem.dup
30
+ p.children = "<semx element='floating-title' source='#{elem['id']}'>" \
31
+ "#{to_xml(p.children)}</semx>"
32
+ elem.next = p
33
+ p.name = "p"
34
+ p["type"] = "floating-title"
35
+ transfer_id(elem, p)
36
+ end
37
+
38
+ def preceding_floating_titles(node, idx)
39
+ out = node.xpath("./preceding-sibling::*")
40
+ .reverse.each_with_object([]) do |p, m|
41
+ %w(note admonition p floating-title).include?(p.name) or break m
42
+ m << p
43
+ end
44
+ #require 'debug'; out.empty? or binding.b
45
+ out.reject { |c| c["displayorder"] }.reverse_each do |c|
46
+ skip_display_order?(c) and next
47
+ c["displayorder"] = idx
48
+ idx += 1
49
+ end
50
+ idx
51
+ end
52
+
53
+ def clausetitle(docxml)
54
+ cjk_extended_title(docxml)
55
+ end
56
+
57
+ def cjk_search
58
+ lang = %w(zh ja ko).map { |x| "@language = '#{x}'" }.join(" or ")
59
+ %(Hans Hant Jpan Hang Kore).include?(@script) and
60
+ lang += " or not(@language)"
61
+ lang
62
+ end
63
+
64
+ def cjk_extended_title(doc)
65
+ l = cjk_search
66
+ doc.xpath(ns("//bibdata/title[#{l}] | //floating-title[#{l}] | " \
67
+ "//fmt-title[@depth = '1' or not(@depth)][#{l}]"))
68
+ .each do |t|
69
+ t.text.size < 4 or next
70
+ t.traverse do |n|
71
+ n.text? or next
72
+ n.replace(@i18n.cjk_extend(n.text))
73
+ end
74
+ end
75
+ end
76
+
77
+ def preceding_floats(clause)
78
+ ret = []
79
+ p = clause
80
+ while prev = p.previous_element
81
+ if prev.name == "floating-title"
82
+ ret << prev
83
+ p = prev
84
+ else break end
85
+ end
86
+ ret
87
+ end
88
+
89
+ def toc_title(docxml)
90
+ docxml.at(ns("//preface/clause[@type = 'toc']")) and return
91
+ ins = toc_title_insert_pt(docxml) or return
92
+ id = UUIDTools::UUID.random_create.to_s
93
+ ins.previous = <<~CLAUSE
94
+ <clause type = 'toc' id='_#{id}'><fmt-title depth='1'>#{@i18n.table_of_contents}</fmt-title></clause>
95
+ CLAUSE
96
+ end
97
+
98
+ def toc_title_insert_pt(docxml)
99
+ ins = docxml.at(ns("//preface")) ||
100
+ docxml.at(ns("//sections | //annex | //bibliography"))
101
+ &.before("<preface> </preface>")
102
+ &.previous_element or return nil
103
+ ins.children.empty? and ins << " "
104
+ ins.children.first
105
+ end
106
+ end
107
+ end
@@ -1,5 +1,18 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def fmt_ref(docxml)
4
+ docxml.xpath(ns("//xref | //eref | //origin | //link")).each do |x|
5
+ sem_xml_descendant?(x) and next
6
+ tag = x.name
7
+ y = Nokogiri::XML::Node.new("fmt-#{tag}", x.document)
8
+ x.attributes.each_key { |a| y[a] = x[a] }
9
+ n = semx_fmt_dup(x) # semx/fmt-xref for ease of processing
10
+ n.children.each { |c| y << c }
11
+ n << y
12
+ x.next = n
13
+ end
14
+ end
15
+
3
16
  def prefix_container(container, linkend, node, target)
4
17
  prefix_container?(container, node) or return linkend
5
18
  container_container = @xrefs.anchor(container, :container, false)
@@ -7,20 +20,21 @@ module IsoDoc
7
20
  prefix_container(container_container,
8
21
  anchor_xref(node, container, container: true),
9
22
  node, target)
10
- l10n(@i18n.nested_xref.sub("%1", container_label)
11
- .sub("%2", linkend))
23
+ l10n(connectives_spans(@i18n.nested_xref
24
+ .sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
25
+ .sub("%2", linkend)))
12
26
  end
13
27
 
14
28
  def anchor_value(id)
15
- @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :value) ||
16
- @xrefs.anchor(id, :label) || @xrefs.anchor(id, :xref)
29
+ @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :label) ||
30
+ @xrefs.anchor(id, :value) || @xrefs.anchor(id, :xref)
17
31
  end
18
32
 
19
33
  def anchor_linkend(node, linkend)
20
34
  node["style"] == "id" and
21
35
  return anchor_id_postproc(node)
22
36
  node["citeas"].nil? && node["bibitemid"] and
23
- return @xrefs.anchor(node["bibitemid"], :xref) || "???"
37
+ return citeas_cleanup(@xrefs.anchor(node["bibitemid"], :xref)) || "???"
24
38
  node.at(ns("./location")) and
25
39
  return combine_xref_locations(node) || "???"
26
40
  node["target"] && node["droploc"] and
@@ -55,14 +69,15 @@ module IsoDoc
55
69
 
56
70
  def anchor_xref_short(node, target, container)
57
71
  if (l = node["label"]) && !container
58
- @i18n.l10n("#{l} #{anchor_value(target)}")
72
+ v = anchor_value(target)
73
+ @i18n.l10n(%[<span class="fmt-element-name">#{l}</span> #{v}])
59
74
  else @xrefs.anchor(target, :xref)
60
75
  end
61
76
  end
62
77
 
63
78
  def anchor_xref_full(num, title)
64
79
  (!title.nil? && !title.empty?) or return nil
65
- l10n("#{num}, #{title}")
80
+ l10n("#{num}<span class='fmt-comma'>,</span> #{title}")
66
81
  end
67
82
 
68
83
  def prefix_container?(container, node)
@@ -116,7 +131,7 @@ module IsoDoc
116
131
  node.xpath(ns("./location")).each_with_object([]) do |l, m|
117
132
  type = @xrefs.anchor(l["target"], :type)
118
133
  m << { conn: l["connective"], target: l["target"],
119
- type: type, node: l, elem: @xrefs.anchor(l["target"], :elem),
134
+ type:, node: l, elem: @xrefs.anchor(l["target"], :elem),
120
135
  container: @xrefs.anchor(l["target"], :container, false) ||
121
136
  %w(termnote).include?(type) }
122
137
  end
@@ -124,7 +139,7 @@ module IsoDoc
124
139
 
125
140
  def loc2xref(entry)
126
141
  if entry[:target]
127
- "<xref nested='true' target='#{entry[:target]}'>#{entry[:label]}</xref>"
142
+ "<fmt-xref nested='true' target='#{entry[:target]}'>#{entry[:label]}</fmt-xref>"
128
143
  else
129
144
  entry[:label]
130
145
  end
@@ -132,20 +147,25 @@ module IsoDoc
132
147
 
133
148
  def combine_conn(list)
134
149
  list.size == 1 and list.first[:label]
135
- if list[1..-1].all? { |l| l[:conn] == "and" }
136
- @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "and")
137
- elsif list[1..-1].all? { |l| l[:conn] == "or" }
138
- @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "or")
150
+ if list[1..].all? { |l| l[:conn] == "and" }
151
+ connectives_spans(@i18n.boolean_conj(list.map do |l|
152
+ loc2xref(l)
153
+ end, "and"))
154
+ elsif list[1..].all? { |l| l[:conn] == "or" }
155
+ connectives_spans(@i18n.boolean_conj(list.map do |l|
156
+ loc2xref(l)
157
+ end, "or"))
139
158
  else
140
159
  ret = loc2xref(list[0])
141
- list[1..-1].each { |l| ret = i18n_chain_boolean(ret, l) }
160
+ list[1..].each { |l| ret = i18n_chain_boolean(ret, l) }
142
161
  ret
143
162
  end
144
163
  end
145
164
 
146
165
  def i18n_chain_boolean(value, entry)
147
- @i18n.send("chain_#{entry[:conn]}").sub("%1", value)
148
- .sub("%2", loc2xref(entry))
166
+ connectives_spans(@i18n.send("chain_#{entry[:conn]}")
167
+ .sub("%1", value)
168
+ .sub("%2", loc2xref(entry)))
149
169
  end
150
170
 
151
171
  def can_conflate_xref_rendering?(locs)
@@ -156,7 +176,7 @@ module IsoDoc
156
176
  end
157
177
 
158
178
  def capitalise_xref(node, linkend, label)
159
- linktext = linkend.gsub(/<[^>]+>/, "")
179
+ linktext = linkend.gsub(/<[^<>]+>/, "")
160
180
  (label && !label.empty? && /^#{Regexp.escape(label)}/.match?(linktext)) ||
161
181
  linktext[0, 1].match?(/\p{Upper}/) and return linkend
162
182
  node["case"] and
@@ -7,6 +7,7 @@ require_relative "presentation_function/erefs"
7
7
  require_relative "presentation_function/inline"
8
8
  require_relative "presentation_function/math"
9
9
  require_relative "presentation_function/section"
10
+ require_relative "presentation_function/index"
10
11
  require_relative "presentation_function/bibdata"
11
12
  require_relative "presentation_function/metadata"
12
13
 
@@ -18,10 +19,13 @@ module IsoDoc
18
19
  super
19
20
  end
20
21
 
21
- def convert1(docxml, _filename, _dir)
22
+ def convert1(docxml, filename, dir)
23
+ @outputdir = dir
24
+ @outputfile = Pathname.new(filename).basename.to_s
22
25
  docid_prefixes(docxml) # feeds @xrefs.parse citation processing
23
26
  @xrefs.parse docxml
24
- info docxml, nil
27
+ @xrefs.klass.meta = @meta
28
+ @xrefs.klass.info docxml, nil
25
29
  conversions(docxml)
26
30
  docxml.root["type"] = "presentation"
27
31
  docxml.to_xml.gsub("&lt;", "&#x3c;").gsub("&gt;", "&#x3e;")
@@ -35,7 +39,7 @@ module IsoDoc
35
39
  end
36
40
 
37
41
  def conversions(docxml)
38
- semantic_xml_insert(docxml)
42
+ #semantic_xml_insert(docxml)
39
43
  metadata docxml
40
44
  bibdata docxml
41
45
  @xrefs.parse docxml
@@ -52,20 +56,21 @@ module IsoDoc
52
56
  # feeds middle_title
53
57
  # triggers xrefs reparse, so put references before all other sections,
54
58
  # which alter titles and thus can alter xrefs
55
- rearrange_clauses docxml # feeds toc, display_order, clausetitle, clause, middle_title
59
+ rearrange_clauses docxml # feeds toc, display_order, clausetitle,
60
+ # clause, middle_title
56
61
  middle_title docxml
62
+ missing_title docxml # feeds clause
57
63
  annex docxml
58
64
  clause docxml # feeds clausetitle
59
65
  term docxml
60
- index docxml
61
66
  clausetitle docxml # feeds floattitle
62
67
  floattitle docxml # feeds rearrange_clauses
68
+ index docxml # fed by strip_duplicate_ids
63
69
  toc docxml
64
70
  display_order docxml
65
71
  end
66
72
 
67
73
  def block(docxml)
68
- amend docxml
69
74
  table docxml
70
75
  figure docxml
71
76
  sourcecode docxml
@@ -74,20 +79,26 @@ module IsoDoc
74
79
  note docxml
75
80
  admonition docxml
76
81
  source docxml
82
+ ul docxml
77
83
  ol docxml
84
+ dl docxml
85
+ quote docxml
78
86
  permission docxml
79
87
  requirement docxml
80
88
  recommendation docxml
81
89
  requirement_render docxml
90
+ amend docxml
82
91
  end
83
92
 
84
93
  def inline(docxml)
85
94
  bibitem_lookup(docxml) # feeds citeas
86
- citeas docxml # feeds xref, eref, origin, quotesource
95
+ fmt_ref docxml # feeds citeas, xref, eref, origin, concept
96
+ citeas docxml # feeds xref, eref, origin, concept
87
97
  xref docxml
88
98
  eref docxml # feeds eref2link
89
99
  origin docxml # feeds eref2link
90
- quotesource docxml # feeds eref2link
100
+ #quotesource docxml # feeds eref2link
101
+ concept docxml
91
102
  eref2link docxml
92
103
  mathml docxml
93
104
  ruby docxml
@@ -99,15 +110,18 @@ module IsoDoc
99
110
  end
100
111
 
101
112
  def terms(docxml)
113
+ termcontainers docxml
102
114
  termexample docxml
103
115
  termnote docxml
104
116
  termdefinition docxml
105
117
  designation docxml
106
118
  termsource docxml
107
- concept docxml
119
+ #concept docxml
108
120
  related docxml
121
+ termcleanup docxml
109
122
  end
110
123
 
124
+ # KILL
111
125
  def semantic_xml_insert(xml)
112
126
  @semantic_xml_insert or return
113
127
  embed = embedable_semantic_xml(xml)
@@ -120,7 +134,7 @@ module IsoDoc
120
134
  def metanorma_extension_insert_pt(xml)
121
135
  xml.at(ns("//metanorma-extension")) ||
122
136
  xml.at(ns("//bibdata"))&.after("<metanorma-extension/>")
123
- &.next_element ||
137
+ &.next_element ||
124
138
  xml.root.elements.first.before("<metanorma-extension/>")
125
139
  .previous_element
126
140
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.10.0".freeze
2
+ VERSION = "3.0.0".freeze
3
3
  end