isodoc 2.4.1 → 2.4.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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/base_style/all.css +29 -0
  3. data/lib/isodoc/base_style/metanorma_word.css +9 -0
  4. data/lib/isodoc/base_style/metanorma_word.scss +11 -0
  5. data/lib/isodoc/base_style/reset.css +29 -0
  6. data/lib/isodoc/base_style/reset.scss +34 -0
  7. data/lib/isodoc/base_style/rouge.css +39 -0
  8. data/lib/isodoc/base_style/typography.scss +1 -1
  9. data/lib/isodoc/convert.rb +10 -3
  10. data/lib/isodoc/function/blocks.rb +29 -16
  11. data/lib/isodoc/function/inline.rb +13 -13
  12. data/lib/isodoc/function/inline_simple.rb +1 -1
  13. data/lib/isodoc/function/references.rb +17 -38
  14. data/lib/isodoc/function/table.rb +1 -1
  15. data/lib/isodoc/function/to_word_html.rb +0 -4
  16. data/lib/isodoc/function/utils.rb +6 -2
  17. data/lib/isodoc/html_function/html.rb +13 -13
  18. data/lib/isodoc/html_function/postprocess.rb +14 -1
  19. data/lib/isodoc/metadata.rb +1 -1
  20. data/lib/isodoc/presentation_function/bibdata.rb +3 -3
  21. data/lib/isodoc/presentation_function/block.rb +1 -98
  22. data/lib/isodoc/presentation_function/math.rb +15 -4
  23. data/lib/isodoc/presentation_function/sourcecode.rb +122 -0
  24. data/lib/isodoc/presentation_function/terms.rb +14 -27
  25. data/lib/isodoc/presentation_xml_convert.rb +38 -0
  26. data/lib/isodoc/version.rb +1 -1
  27. data/lib/isodoc/word_function/body.rb +19 -19
  28. data/lib/isodoc/word_function/comments.rb +23 -18
  29. data/lib/isodoc/word_function/footnotes.rb +8 -8
  30. data/lib/isodoc/word_function/postprocess.rb +25 -118
  31. data/lib/isodoc/word_function/postprocess_cover.rb +29 -157
  32. data/lib/isodoc/word_function/postprocess_table.rb +85 -0
  33. data/lib/isodoc/word_function/postprocess_toc.rb +165 -0
  34. data/lib/isodoc/word_function/table.rb +34 -15
  35. data/lib/isodoc/xref/xref_gen.rb +2 -4
  36. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba10d3ff61b6c99d2251fd1d8e868bf09aea5dde1da505bc1745003778f8750d
4
- data.tar.gz: b758cac0f031d6a16c95ba8dd05c963bf227438d64d63f1f3146dd745d5c42e9
3
+ metadata.gz: a0720c3026536785125b4c6c495e4f2573dfa7b2186094c0f36efa9c20a1fbd3
4
+ data.tar.gz: 9ea3325d067e417956b865edd0baf70dff9a5cb80008e6dfe5fbfbdaaaf16ff4
5
5
  SHA512:
6
- metadata.gz: 1ba1187b3202d8b8ef7d8c0376ba6cd100230a0cbe889cfaa729510f174cdbfba884b2ca2b5607525b53391b83a007313e21427539aa8c42d604d295b90feb3b
7
- data.tar.gz: 0b15b2d4bee5c08e2a0989eba6909d37827f67943eb8f0e86f9815f202ca7f408955b1905c7d041e32ae1433ddc1fa99e7fdecf4bf49c0174ee194731104135f
6
+ metadata.gz: 2e97827c7adacaa26ef823222897672413056219fba5a3e0a6dee92079ac680cd50a9f1dde9cb7c40fddf23ef000fcb0478709a95916a4e6b222bf3d4e94ca54
7
+ data.tar.gz: 888734821add95629f8709aac1e5ac8b95b372b6a33d43e366e78e0c4ec6a3957dc9264a86015501458ca2752b881f44053e1f7a3997c5d0fb1b43ec816abc74
@@ -124,6 +124,35 @@ a.FootnoteRef + a.FootnoteRef:before {
124
124
  color: red;
125
125
  text-decoration: line-through; }
126
126
 
127
+ /* code highlighting with line numbers */
128
+ table.rouge-line-table td.rouge-gutter {
129
+ -moz-user-select: none;
130
+ -ms-user-select: none;
131
+ -webkit-user-select: none;
132
+ user-select: none;
133
+ padding-right: 1em; }
134
+
135
+ table.rouge-line-table td.rouge-code {
136
+ -moz-user-select: all;
137
+ -ms-user-select: all;
138
+ -webkit-user-select: all;
139
+ user-select: all; }
140
+
141
+ table.rouge-line-table,
142
+ table.rouge-line-table th,
143
+ table.rouge-line-table td {
144
+ width: auto;
145
+ border: none;
146
+ margin: 0;
147
+ padding: 0;
148
+ font-size: 100%; }
149
+
150
+ table.rouge-line-table pre {
151
+ margin: 0;
152
+ padding: 0;
153
+ overflow-x: visible;
154
+ font-size: 100%; }
155
+
127
156
  #standard-band {
128
157
  background-color: #0AC442; }
129
158
 
@@ -45,3 +45,12 @@ span.addition {
45
45
  span.deletion {
46
46
  color: red;
47
47
  text-decoration: line-through; }
48
+
49
+ table.rouge-line-table {
50
+ border: none;
51
+ mso-border-alt: none;
52
+ mso-border-insideh: none;
53
+ mso-border-insidev: none; }
54
+
55
+ td.rouge-code p.Sourcecode {
56
+ margin: 0px; }
@@ -42,3 +42,14 @@ span.deletion {
42
42
  color: red;
43
43
  text-decoration: line-through;
44
44
  }
45
+
46
+ table.rouge-line-table {
47
+ border:none;
48
+ mso-border-alt:none;
49
+ mso-border-insideh:none;
50
+ mso-border-insidev:none;
51
+ }
52
+
53
+ td.rouge-code p.Sourcecode {
54
+ margin: 0px;
55
+ }
@@ -123,3 +123,32 @@ a.FootnoteRef + a.FootnoteRef:before {
123
123
  .deletion {
124
124
  color: red;
125
125
  text-decoration: line-through; }
126
+
127
+ /* code highlighting with line numbers */
128
+ table.rouge-line-table td.rouge-gutter {
129
+ -moz-user-select: none;
130
+ -ms-user-select: none;
131
+ -webkit-user-select: none;
132
+ user-select: none;
133
+ padding-right: 1em; }
134
+
135
+ table.rouge-line-table td.rouge-code {
136
+ -moz-user-select: all;
137
+ -ms-user-select: all;
138
+ -webkit-user-select: all;
139
+ user-select: all; }
140
+
141
+ table.rouge-line-table,
142
+ table.rouge-line-table th,
143
+ table.rouge-line-table td {
144
+ width: auto;
145
+ border: none;
146
+ margin: 0;
147
+ padding: 0;
148
+ font-size: 100%; }
149
+
150
+ table.rouge-line-table pre {
151
+ margin: 0;
152
+ padding: 0;
153
+ overflow-x: visible;
154
+ font-size: 100%; }
@@ -152,3 +152,37 @@ a.FootnoteRef + a.FootnoteRef:before {
152
152
  color: red;
153
153
  text-decoration: line-through;
154
154
  }
155
+
156
+ /* code highlighting with line numbers */
157
+
158
+ table.rouge-line-table td.rouge-gutter {
159
+ -moz-user-select: none;
160
+ -ms-user-select: none;
161
+ -webkit-user-select: none;
162
+ user-select: none;
163
+ padding-right: 1em;
164
+ }
165
+
166
+ table.rouge-line-table td.rouge-code {
167
+ -moz-user-select: all;
168
+ -ms-user-select: all;
169
+ -webkit-user-select: all;
170
+ user-select: all;
171
+ }
172
+
173
+ table.rouge-line-table,
174
+ table.rouge-line-table th,
175
+ table.rouge-line-table td {
176
+ width: auto;
177
+ border: none;
178
+ margin: 0;
179
+ padding: 0;
180
+ font-size: 100%;
181
+ }
182
+
183
+ table.rouge-line-table pre {
184
+ margin: 0;
185
+ padding: 0;
186
+ overflow-x: visible;
187
+ font-size: 100%;
188
+ }
@@ -0,0 +1,39 @@
1
+ sourcecode table td { padding: 5px; }
2
+ sourcecode table pre { margin: 0; }
3
+ sourcecode, sourcecode .w {
4
+ color: #444444;
5
+ }
6
+ sourcecode .cp {
7
+ color: #CC00A3;
8
+ }
9
+ sourcecode .cs {
10
+ color: #CC00A3;
11
+ }
12
+ sourcecode .c, sourcecode .ch, sourcecode .cd, sourcecode .cm, sourcecode .cpf, sourcecode .c1 {
13
+ color: #FF0000;
14
+ }
15
+ sourcecode .kc {
16
+ color: #C34E00;
17
+ }
18
+ sourcecode .kd {
19
+ color: #0000FF;
20
+ }
21
+ sourcecode .kr {
22
+ color: #007575;
23
+ }
24
+ sourcecode .k, sourcecode .kn, sourcecode .kp, sourcecode .kt, sourcecode .kv {
25
+ color: #0000FF;
26
+ }
27
+ sourcecode .s, sourcecode .sb, sourcecode .sc, sourcecode .ld, sourcecode .sd, sourcecode .s2, sourcecode .se, sourcecode .sh, sourcecode .si, sourcecode .sx, sourcecode .sr, sourcecode .s1, sourcecode .ss {
28
+ color: #009C00;
29
+ }
30
+ sourcecode .sa {
31
+ color: #0000FF;
32
+ }
33
+ sourcecode .nb, sourcecode .bp {
34
+ color: #C34E00;
35
+ }
36
+ sourcecode .nt {
37
+ color: #0000FF;
38
+ }
39
+
@@ -65,6 +65,6 @@
65
65
  padding: 1em;
66
66
  }
67
67
  td.header {
68
- font-weigth: 400;
68
+ font-weight: 400;
69
69
  }
70
70
  }
@@ -50,6 +50,8 @@ module IsoDoc
50
50
  # fontlicenseagreement: fontist font license agreement
51
51
  # modspecidentifierbase: base prefix for any Modspec identifiers
52
52
  # sourcehighlighter: whether to apply sourcecode highlighting
53
+ # semantic_xml_insert: whether to insert into presentation XML
54
+ # a copy of semantic XML
53
55
  def initialize(options) # rubocop:disable Lint/MissingSuper
54
56
  @options = options_preprocess(options)
55
57
  init_stylesheets(@options)
@@ -60,6 +62,7 @@ module IsoDoc
60
62
  init_locations(@options)
61
63
  init_i18n(@options)
62
64
  init_rendering(@options)
65
+ init_arrangement(@options)
63
66
  end
64
67
 
65
68
  def options_preprocess(options)
@@ -77,14 +80,18 @@ module IsoDoc
77
80
  @datauriimage = options[:datauriimage]
78
81
  @suppressheadingnumbers = options[:suppressheadingnumbers]
79
82
  @break_up_urls_in_tables = options[:breakupurlsintables]
80
- @sectionsplit = options[:sectionsplit] == "true"
81
83
  @suppressasciimathdup = options[:suppressasciimathdup]
82
- @bare = options[:bare]
83
84
  @aligncrosselements = options[:aligncrosselements]
84
85
  @modspecidentifierbase = options[:modspecidentifierbase]
85
86
  @sourcehighlighter = options[:sourcehighlighter]
86
87
  end
87
88
 
89
+ def init_arrangement(options)
90
+ @sectionsplit = options[:sectionsplit] == "true"
91
+ @bare = options[:bare]
92
+ @semantic_xml_insert = options[:semanticxmlinsert] != "false"
93
+ end
94
+
88
95
  def init_i18n(options)
89
96
  @i18nyaml = options[:i18nyaml]
90
97
  @lang = options[:language] || "en"
@@ -187,7 +194,7 @@ module IsoDoc
187
194
  @xrefs.parse docxml
188
195
  bibitem_lookup(docxml)
189
196
  noko do |xml|
190
- xml.html **{ lang: @lang.to_s } do |html|
197
+ xml.html lang: @lang.to_s do |html|
191
198
  html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
192
199
  info docxml, nil
193
200
  populate_css
@@ -6,19 +6,19 @@ module IsoDoc
6
6
  @annotation = false
7
7
 
8
8
  def middle_title(_isoxml, out)
9
- out.p(**{ class: "zzSTDTitle1" }) { |p| p << @meta.get[:doctitle] }
9
+ out.p(class: "zzSTDTitle1") { |p| p << @meta.get[:doctitle] }
10
10
  end
11
11
 
12
12
  def figure_name_parse(_node, div, name)
13
13
  return if name.nil?
14
14
 
15
- div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
15
+ div.p class: "FigureTitle", style: "text-align:center;" do |p|
16
16
  name.children.each { |n| parse(n, p) }
17
17
  end
18
18
  end
19
19
 
20
20
  def figure_key(out)
21
- out.p **{ style: "page-break-after:avoid;" } do |p|
21
+ out.p style: "page-break-after:avoid;" do |p|
22
22
  p.b { |b| b << @i18n.key }
23
23
  end
24
24
  end
@@ -63,7 +63,7 @@ module IsoDoc
63
63
  def sourcecode_name_parse(_node, div, name)
64
64
  return if name.nil?
65
65
 
66
- div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
66
+ div.p class: "SourceTitle", style: "text-align:center;" do |p|
67
67
  name.children.each { |n| parse(n, p) }
68
68
  end
69
69
  end
@@ -75,13 +75,22 @@ module IsoDoc
75
75
  def sourcecode_parse(node, out)
76
76
  name = node.at(ns("./name"))
77
77
  out.p **sourcecode_attrs(node) do |div|
78
- @sourcecode = true unless node.at(ns(".//sourcecode"))
79
- node.children.each { |n| parse(n, div) unless n.name == "name" }
80
- @sourcecode = false
78
+ sourcecode_parse1(node, div)
81
79
  end
82
80
  sourcecode_name_parse(node, out, name)
83
81
  end
84
82
 
83
+ def sourcecode_parse1(node, div)
84
+ @sourcecode = "pre"
85
+ node.at(ns(".//table[@class = 'rouge-line-table']")) ||
86
+ node.at("./ancestor::xmlns:table[@class = 'rouge-line-table']") and
87
+ @sourcecode = "table"
88
+ # !node.ancestors("table").empty? and
89
+ # @sourcecode = "table"
90
+ node.children.each { |n| parse(n, div) unless n.name == "name" }
91
+ @sourcecode = false
92
+ end
93
+
85
94
  def pre_parse(node, out)
86
95
  out.pre node.text, **attr_code(id: node["id"])
87
96
  end
@@ -89,18 +98,22 @@ module IsoDoc
89
98
  def annotation_parse(node, out)
90
99
  @sourcecode = false
91
100
  @annotation = true
92
- node.at("./preceding-sibling::*[local-name() = 'annotation']") or
93
- out << "<br/>"
94
- callout = node.at(ns("//callout[@target='#{node['id']}']"))
95
- out << "<br/>&lt;#{callout.text}&gt; "
96
- out << node&.children&.text&.strip
97
- @annotation = false
101
+ out.div class: "annotation" do |div|
102
+ # node.at("./preceding-sibling::*[local-name() = 'annotation']") or
103
+ # div << "<br/>"
104
+ callout = node.at(ns("//callout[@target='#{node['id']}']"))
105
+ div << "<span class='c'>&lt;#{callout.text}&gt;</span> "
106
+ div << "<span class='c'>#{node.children&.text&.strip}</span>"
107
+ node.at("./following-sibling::*[local-name() = 'annotation']") and
108
+ div << "<br/>"
109
+ @annotation = false
110
+ end
98
111
  end
99
112
 
100
113
  def formula_where(dlist, out)
101
114
  return unless dlist
102
115
 
103
- out.p **{ style: "page-break-after:avoid;" } do |p|
116
+ out.p style: "page-break-after:avoid;" do |p|
104
117
  p << @i18n.where
105
118
  end
106
119
  parse(dlist, out)
@@ -168,7 +181,7 @@ module IsoDoc
168
181
  source = node.at(ns("./source"))
169
182
  return if author.nil? && source.nil?
170
183
 
171
- out.p **{ class: "QuoteAttribution" } do |p|
184
+ out.p class: "QuoteAttribution" do |p|
172
185
  p << "&#x2014; #{author.text}" if author
173
186
  p << ", " if author && source
174
187
  eref_parse(source, p) if source
@@ -198,7 +211,7 @@ module IsoDoc
198
211
  end
199
212
 
200
213
  def toc_parse(node, out)
201
- out.div **{ class: "toc" } do |div|
214
+ out.div class: "toc" do |div|
202
215
  node.children.each { |n| parse(n, div) }
203
216
  end
204
217
  end
@@ -42,7 +42,7 @@ module IsoDoc
42
42
  else
43
43
  "##{node['target']}"
44
44
  end
45
- out.a(**{ href: target }) { |l| no_locality_parse(node, l) }
45
+ out.a(href: target) { |l| no_locality_parse(node, l) }
46
46
  end
47
47
 
48
48
  def suffix_url(url)
@@ -77,10 +77,10 @@ module IsoDoc
77
77
  if href = eref_target(node)
78
78
  if node["type"] == "footnote"
79
79
  out.sup do |s|
80
- s.a(**{ href: href }) { |l| no_locality_parse(node, l) }
80
+ s.a(href: href) { |l| no_locality_parse(node, l) }
81
81
  end
82
82
  else
83
- out.a(**{ href: href }) { |l| no_locality_parse(node, l) }
83
+ out.a(href: href) { |l| no_locality_parse(node, l) }
84
84
  end
85
85
  else no_locality_parse(node, out)
86
86
  end
@@ -109,7 +109,7 @@ module IsoDoc
109
109
  when "LaTeX" then latexmath_parse(node)
110
110
  else HTMLEntities.new.encode(node.text)
111
111
  end
112
- out.span **{ class: "stem" } do |span|
112
+ out.span class: "stem" do |span|
113
113
  span.parent.add_child ooml
114
114
  end
115
115
  end
@@ -123,7 +123,7 @@ module IsoDoc
123
123
  def asciimath_parse(node)
124
124
  a = node.at(ns("./asciimath"))&.text || node.text
125
125
 
126
- "#{@openmathdelim}#{HTMLEntities.new.encode(a)}"\
126
+ "#{@openmathdelim}#{HTMLEntities.new.encode(a)}" \
127
127
  "#{@closemathdelim}"
128
128
  end
129
129
 
@@ -134,7 +134,7 @@ module IsoDoc
134
134
 
135
135
  def image_title_parse(out, caption)
136
136
  unless caption.nil?
137
- out.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
137
+ out.p class: "FigureTitle", style: "text-align:center;" do |p|
138
138
  p.b { |b| b << caption.to_s }
139
139
  end
140
140
  end
@@ -151,7 +151,7 @@ module IsoDoc
151
151
  end
152
152
 
153
153
  def smallcap_parse(node, xml)
154
- xml.span **{ style: "font-variant:small-caps;" } do |s|
154
+ xml.span style: "font-variant:small-caps;" do |s|
155
155
  node.children.each { |n| parse(n, s) }
156
156
  end
157
157
  end
@@ -160,21 +160,21 @@ module IsoDoc
160
160
  return if node.nil? || node.text.nil?
161
161
 
162
162
  text = node.to_s
163
- if in_sourcecode
163
+ @sourcecode == "pre" and
164
164
  text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/>&#xa0;")
165
- .gsub(/ (?= )/, "&#xa0;")
166
- end
165
+ @sourcecode and
166
+ text = text.gsub(/ (?= )/, "&#xa0;")
167
167
  out << text
168
168
  end
169
169
 
170
170
  def add_parse(node, out)
171
- out.span **{ class: "addition" } do |e|
171
+ out.span class: "addition" do |e|
172
172
  node.children.each { |n| parse(n, e) }
173
173
  end
174
174
  end
175
175
 
176
176
  def del_parse(node, out)
177
- out.span **{ class: "deletion" } do |e|
177
+ out.span class: "deletion" do |e|
178
178
  node.children.each { |n| parse(n, e) }
179
179
  end
180
180
  end
@@ -182,7 +182,7 @@ module IsoDoc
182
182
  def error_parse(node, out)
183
183
  text = node.to_xml.gsub(/</, "&lt;").gsub(/>/, "&gt;")
184
184
  out.para do |p|
185
- p.b(**{ role: "strong" }) { |e| e << text }
185
+ p.b(role: "strong") { |e| e << text }
186
186
  end
187
187
  end
188
188
  end
@@ -30,7 +30,7 @@ module IsoDoc
30
30
  end
31
31
 
32
32
  def keyword_parse(node, out)
33
- out.span **{ class: "keyword" } do |s|
33
+ out.span class: "keyword" do |s|
34
34
  node.children.each { |n| parse(n, s) }
35
35
  end
36
36
  end
@@ -4,55 +4,35 @@ module IsoDoc
4
4
  # This is highly specific to ISO, but it's not a bad precedent for
5
5
  # references anyway; keeping here instead of in IsoDoc::Iso for now
6
6
  def docid_l10n(text)
7
- return text if text.nil?
8
-
9
- text.gsub(/All Parts/i, @i18n.all_parts.downcase) if @i18n.all_parts
7
+ text.nil? and return text
8
+ @i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
9
+ text.size < 20 and text.gsub!(/ /, "&#xa0;")
10
10
  text
11
11
  end
12
12
 
13
- def nonstd_bibitem(list, bib, _ordinal, biblio) # %%%
13
+ def nonstd_bibitem(list, bib, _ordinal, biblio)
14
14
  list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
15
- # ids = bibitem_ref_code(bib)
16
- # idents = render_identifier(ids)
17
- # if biblio then ref_entry_code(ref, ordinal, idents, ids)
18
- # else
19
- # ref << (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
20
- # ref << ", #{idents[sdo]}" if idents[:ordinal] && idents[:sdo]
21
- # end
22
- # ref << "," if idents[:sdo]
23
15
  tag = bib.at(ns("./biblio-tag"))
24
16
  tag&.children&.each { |n| parse(n, ref) }
25
17
  reference_format(bib, ref)
26
18
  end
27
19
  end
28
20
 
29
- def std_bibitem_entry(list, bib, _ordinal, biblio) # %%%
21
+ def std_bibitem_entry(list, bib, _ordinal, biblio)
30
22
  list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
31
- # idents = render_identifier(bibitem_ref_code(bib))
32
- # if biblio then ref_entry_code(ref, ordinal, idents, nil)
33
- # else
34
- # ref << (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
35
- # ref << ", #{idents[:sdo]}" if (idents[:ordinal] ||
36
- # idents[:metanorma]) && idents[:sdo]
37
- # end
38
- # date_note_process(bib, ref)
39
- # ref << "," if idents[:sdo]
40
23
  tag = bib.at(ns("./biblio-tag"))
41
24
  tag&.children&.each { |n| parse(n, ref) }
42
25
  reference_format(bib, ref)
43
26
  end
44
27
  end
45
28
 
46
- # # if ids is just a number, only use that ([1] Non-Standard)
47
- # # else, use both ordinal, as prefix, and ids
48
- # def ref_entry_code(ref, ordinal, ids, _id) #%%%
49
- # prefix_bracketed_ref(ref, ids[:ordinal] || ids[:metanorma] ||
50
- # "[#{ordinal}]")
51
- # ids[:sdo] and ref << (ids[:sdo]).to_s
52
- # end
29
+ SKIP_DOCID = <<~XPATH.strip.freeze
30
+ @type = 'DOI' or @type = 'doi' or @type = 'ISSN' or @type = 'issn' or @type = 'ISBN' or @type = 'isbn' or starts-with(@type, 'ISSN.') or starts-with(@type, 'ISBN.') or starts-with(@type, 'issn.') or starts-with(@type, 'isbn.')
31
+ XPATH
53
32
 
54
- SKIP_DOCID = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or " \
55
- "@type = 'metanorma-ordinal' or @type = 'ISBN'".freeze
33
+ SKIP_DOC1 = <<~XPATH.strip.freeze
34
+ #{SKIP_DOCID} or @type = 'metanorma-ordinal' or @type = 'metanorma'
35
+ XPATH
56
36
 
57
37
  def pref_ref_code(bib)
58
38
  bib["suppress_identifier"] == "true" and return nil
@@ -61,8 +41,8 @@ module IsoDoc
61
41
  ret.empty? and
62
42
  ret = bib.xpath(ns("./docidentifier[@primary = 'true']"))
63
43
  ret.empty? and
64
- ret = bib.at(ns("./docidentifier[not(#{SKIP_DOCID})]#{lang}")) ||
65
- bib.at(ns("./docidentifier[not(#{SKIP_DOCID})]"))
44
+ ret = bib.at(ns("./docidentifier[not(#{SKIP_DOC1})]#{lang}")) ||
45
+ bib.at(ns("./docidentifier[not(#{SKIP_DOC1})]"))
66
46
  ret
67
47
  end
68
48
 
@@ -70,8 +50,7 @@ module IsoDoc
70
50
  def bibitem_ref_code(bib)
71
51
  id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
72
52
  id1 = pref_ref_code(bib)
73
- id2 = bib.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or " \
74
- "@type = 'ISBN']"))
53
+ id2 = bib.at(ns("./docidentifier[#{SKIP_DOCID}]"))
75
54
  id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
76
55
  return [id, id1, id2, id3] if id || id1 || id2 || id3
77
56
  return [nil, nil, nil, nil] if bib["suppress_identifier"] == "true"
@@ -139,9 +118,9 @@ module IsoDoc
139
118
 
140
119
  def standard?(bib)
141
120
  ret = false
142
- drop = %w(metanorma DOI ISSN ISBN)
143
121
  bib.xpath(ns("./docidentifier")).each do |id|
144
- next if id["type"].nil? || drop.include?(id["type"])
122
+ next if id["type"].nil? ||
123
+ id.at(".//self::*[#{SKIP_DOCID} or @type = 'metanorma']")
145
124
 
146
125
  ret = true
147
126
  end
@@ -194,7 +173,7 @@ module IsoDoc
194
173
  return
195
174
  page_break(out)
196
175
  out.div do |div|
197
- div.h1 **{ class: "Section3" } do |h1|
176
+ div.h1 class: "Section3" do |h1|
198
177
  f.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
199
178
  end
200
179
  biblio_list(f, div, true)
@@ -103,7 +103,7 @@ module IsoDoc
103
103
  !header && cell.name == "th" and
104
104
  scope = (cell["rowspan"] ? "rowgroup" : "row")
105
105
  { rowspan: cell["rowspan"], colspan: cell["colspan"],
106
- style: style.gsub(/\n/, ""), scope: scope }
106
+ style: style.gsub(/\n/, ""), scope: scope, class: cell["class"] }
107
107
  end
108
108
 
109
109
  def make_tr_attr_style(row, rowmax, totalrows, _header, bordered)
@@ -8,10 +8,6 @@ module IsoDoc
8
8
  @termdomain = termdomain
9
9
  end
10
10
 
11
- def in_sourcecode
12
- @sourcecode
13
- end
14
-
15
11
  def note?
16
12
  @note
17
13
  end
@@ -37,10 +37,14 @@ module IsoDoc
37
37
  DOCTYPE_HDR = "<!DOCTYPE html SYSTEM " \
38
38
  '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.freeze
39
39
 
40
+ HUGESTRICT =
41
+ Nokogiri::XML::ParseOptions::HUGE |
42
+ Nokogiri::XML::ParseOptions::STRICT
43
+
40
44
  def to_xhtml(xml)
41
45
  xml = to_xhtml_prep(xml)
42
46
  begin
43
- Nokogiri::XML.parse(xml, &:strict)
47
+ Nokogiri::XML.parse(xml, nil, nil, HUGESTRICT)
44
48
  rescue Nokogiri::XML::SyntaxError => e
45
49
  File.open("#{@filename}.#{@format}.err", "w:UTF-8") do |f|
46
50
  f.write xml
@@ -65,7 +69,7 @@ module IsoDoc
65
69
  end
66
70
 
67
71
  def from_xhtml(xml)
68
- numeric_escapes(xml.to_xml
72
+ numeric_escapes(to_xml(xml)
69
73
  .sub(%r{ xmlns="http://www.w3.org/1999/xhtml"}, ""))
70
74
  end
71
75